├── .github └── workflows │ └── cmake-single-platform.yml ├── .gitignore ├── .gitmodules ├── CI └── perf_counter_template_gcc │ ├── .mxproject │ ├── Core │ ├── Inc │ │ ├── main.h │ │ ├── stm32f1xx_hal_conf.h │ │ └── stm32f1xx_it.h │ └── Src │ │ ├── stm32f1xx_hal_msp.c │ │ ├── stm32f1xx_it.c │ │ └── system_stm32f1xx.c │ ├── Drivers │ ├── CMSIS │ │ ├── Device │ │ │ └── ST │ │ │ │ └── STM32F1xx │ │ │ │ └── Include │ │ │ │ ├── stm32f103xe.h │ │ │ │ ├── stm32f1xx.h │ │ │ │ └── system_stm32f1xx.h │ │ └── Include │ │ │ ├── cmsis_armcc.h │ │ │ ├── cmsis_armclang.h │ │ │ ├── cmsis_compiler.h │ │ │ ├── cmsis_gcc.h │ │ │ ├── cmsis_iccarm.h │ │ │ ├── cmsis_version.h │ │ │ ├── core_armv8mbl.h │ │ │ ├── core_armv8mml.h │ │ │ ├── core_cm0.h │ │ │ ├── core_cm0plus.h │ │ │ ├── core_cm1.h │ │ │ ├── core_cm23.h │ │ │ ├── core_cm3.h │ │ │ ├── core_cm33.h │ │ │ ├── core_cm4.h │ │ │ ├── core_cm7.h │ │ │ ├── core_sc000.h │ │ │ ├── core_sc300.h │ │ │ ├── mpu_armv7.h │ │ │ ├── mpu_armv8.h │ │ │ └── tz_context.h │ └── STM32F1xx_HAL_Driver │ │ ├── Inc │ │ ├── Legacy │ │ │ └── stm32_hal_legacy.h │ │ ├── stm32f1xx_hal.h │ │ ├── stm32f1xx_hal_cortex.h │ │ ├── stm32f1xx_hal_def.h │ │ ├── stm32f1xx_hal_dma.h │ │ ├── stm32f1xx_hal_dma_ex.h │ │ ├── stm32f1xx_hal_exti.h │ │ ├── stm32f1xx_hal_flash.h │ │ ├── stm32f1xx_hal_flash_ex.h │ │ ├── stm32f1xx_hal_gpio.h │ │ ├── stm32f1xx_hal_gpio_ex.h │ │ ├── stm32f1xx_hal_pwr.h │ │ ├── stm32f1xx_hal_rcc.h │ │ ├── stm32f1xx_hal_rcc_ex.h │ │ ├── stm32f1xx_hal_tim.h │ │ └── stm32f1xx_hal_tim_ex.h │ │ └── Src │ │ ├── stm32f1xx_hal.c │ │ ├── stm32f1xx_hal_cortex.c │ │ ├── stm32f1xx_hal_dma.c │ │ ├── stm32f1xx_hal_exti.c │ │ ├── stm32f1xx_hal_flash.c │ │ ├── stm32f1xx_hal_flash_ex.c │ │ ├── stm32f1xx_hal_gpio.c │ │ ├── stm32f1xx_hal_gpio_ex.c │ │ ├── stm32f1xx_hal_pwr.c │ │ ├── stm32f1xx_hal_rcc.c │ │ ├── stm32f1xx_hal_rcc_ex.c │ │ ├── stm32f1xx_hal_tim.c │ │ └── stm32f1xx_hal_tim_ex.c │ ├── MDK-ARM │ ├── perf_counter_template_gcc.uvoptx │ ├── perf_counter_template_gcc.uvprojx │ └── startup_stm32f103xe.s │ ├── Makefile │ ├── STM32F103RCTx_FLASH.ld │ ├── perf_counter_template_gcc.ioc │ ├── platform.c │ └── startup_stm32f103xe.s ├── Doxyfile ├── GorgonMeducer.perf_counter.pdsc ├── LICENSE ├── README.md ├── SConscript ├── benchmark └── coremark_port │ ├── core_main.c │ ├── core_portme.c │ ├── core_portme.h │ └── core_portme.mak ├── cmsis-pack ├── GorgonMeducer.perf_counter.2.4.0.pack ├── GorgonMeducer.perf_counter.pdsc └── GorgonMeducer.pidx ├── documents └── pictures │ ├── GNU_in_AC5 │ ├── RTE │ ├── RTE_cmsis_core │ ├── __cpu_perf__output.png │ ├── __cycleof___output_non_printf │ ├── __cycleof___output_simple │ ├── check_for_updates │ ├── gnu_in_ac6 │ ├── pack_installer │ └── rt-thread-settings.png ├── example ├── RTE │ ├── Compiler │ │ └── EventRecorderConf.h │ ├── Device │ │ ├── ARMCM0 │ │ │ ├── ARMCM0_ac6.sct │ │ │ ├── gcc_arm.ld │ │ │ ├── startup_ARMCM0.c │ │ │ ├── startup_ARMCM0.s │ │ │ └── system_ARMCM0.c │ │ ├── ARMCM3 │ │ │ ├── startup_ARMCM3.s │ │ │ └── system_ARMCM3.c │ │ ├── CMSDK_CM0 │ │ │ ├── RTE_Device.h │ │ │ ├── startup_CMSDK_CM0.s │ │ │ └── system_CMSDK_CM0.c │ │ ├── CMSDK_CM3 │ │ │ ├── RTE_Device.h │ │ │ ├── startup_CMSDK_CM3.s │ │ │ └── system_CMSDK_CM3.c │ │ └── CMSDK_CM7_SP │ │ │ ├── RTE_Device.h │ │ │ ├── startup_CMSDK_CM7.s │ │ │ └── system_CMSDK_CM7.c │ └── RTOS │ │ ├── board.c │ │ └── rtconfig.h ├── copy.bat ├── example.sct ├── example.uvguix ├── example.uvmpw ├── example.uvoptx ├── example.uvprojx ├── gcc │ ├── gcc_arm.ld │ ├── startup_ARMCM0.c │ ├── startup_ARMCM7.S │ └── system_ARMCM0.c ├── gcc_example.uvoptx ├── gcc_example.uvprojx ├── main.c ├── platform.c └── stdout_USART.c ├── gen_pack.sh ├── os ├── perf_os_patch_freertos.c ├── perf_os_patch_rt_thread.c ├── perf_os_patch_rtx5.c └── perf_os_patch_threadx.c ├── perf_counter.c ├── perf_counter.h ├── perfc_port_default.c ├── perfc_port_default.h ├── perfc_port_pmu.c ├── perfc_port_pmu.h ├── systick_wrapper_gcc.S ├── systick_wrapper_gnu.s ├── systick_wrapper_ual.s └── template ├── perfc_port_user.c └── perfc_port_user.h /.github/workflows/cmake-single-platform.yml: -------------------------------------------------------------------------------- 1 | name: Build documentation and pack 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: [ developing ] 6 | pull_request: 7 | branches: [ developing ] 8 | release: 9 | types: [published] 10 | jobs: 11 | pack: 12 | name: Generate pack 13 | runs-on: ubuntu-22.04 14 | steps: 15 | - uses: actions/checkout@v3 16 | with: 17 | fetch-depth: 0 18 | 19 | - name: Fetch tags 20 | if: ${{ github.event_name == 'release' }} 21 | run: | 22 | git fetch --tags --force 23 | 24 | - name: get submodules 25 | run: | 26 | git submodule update --init 27 | 28 | - uses: Open-CMSIS-Pack/gen-pack-action@main 29 | with: 30 | doxygen-version: 1.9.5 31 | packchk-version: 1.3.96 32 | gen-pack-script: ./gen_pack.sh 33 | gen-pack-output: ./output 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.axf 3 | *.dep 4 | *.d 5 | *.o 6 | *.Scr 7 | *.gabwan01 8 | *.map 9 | *.lnp 10 | example/Out 11 | *.scvd 12 | *.iex 13 | *.crf 14 | *.lst 15 | example/GCC_Out 16 | documents/.DS_Store 17 | documents/Doxygen 18 | *@* 19 | RTE_Components.h 20 | *uvgui.* 21 | *uvguix.* 22 | ArInp.bat 23 | Pre_Include_Global.h 24 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "benchmark/coremark"] 2 | path = benchmark/coremark 3 | url = https://github.com/eembc/coremark 4 | -------------------------------------------------------------------------------- /CI/perf_counter_template_gcc/.mxproject: -------------------------------------------------------------------------------- 1 | [PreviousLibFiles] 2 | LibFiles=Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_exti.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h;Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_exti.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xe.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/cmsis_version.h;Drivers/CMSIS/Include/core_armv8mbl.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/mpu_armv7.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/tz_context.h; 3 | 4 | [PreviousUsedKeilFiles] 5 | SourceFiles=..\Core\Src\main.c;..\Core\Src\stm32f1xx_it.c;..\Core\Src\stm32f1xx_hal_msp.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c;..\Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;..\Core\Src/system_stm32f1xx.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;..\Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c;..\Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;..\Core\Src/system_stm32f1xx.c;;; 6 | HeaderPath=..\Drivers\STM32F1xx_HAL_Driver\Inc;..\Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;..\Drivers\CMSIS\Device\ST\STM32F1xx\Include;..\Drivers\CMSIS\Include;..\Core\Inc; 7 | CDefines=USE_HAL_DRIVER;STM32F103xE;USE_HAL_DRIVER;USE_HAL_DRIVER; 8 | 9 | [PreviousGenFiles] 10 | AdvancedFolderStructure=true 11 | HeaderFileListSize=3 12 | HeaderFiles#0=C:/Users/lyon/Desktop/perf_counter_template_gcc/Core/Inc/stm32f1xx_it.h 13 | HeaderFiles#1=C:/Users/lyon/Desktop/perf_counter_template_gcc/Core/Inc/stm32f1xx_hal_conf.h 14 | HeaderFiles#2=C:/Users/lyon/Desktop/perf_counter_template_gcc/Core/Inc/main.h 15 | HeaderFolderListSize=1 16 | HeaderPath#0=C:/Users/lyon/Desktop/perf_counter_template_gcc/Core/Inc 17 | HeaderFiles=; 18 | SourceFileListSize=3 19 | SourceFiles#0=C:/Users/lyon/Desktop/perf_counter_template_gcc/Core/Src/stm32f1xx_it.c 20 | SourceFiles#1=C:/Users/lyon/Desktop/perf_counter_template_gcc/Core/Src/stm32f1xx_hal_msp.c 21 | SourceFiles#2=C:/Users/lyon/Desktop/perf_counter_template_gcc/Core/Src/main.c 22 | SourceFolderListSize=1 23 | SourcePath#0=C:/Users/lyon/Desktop/perf_counter_template_gcc/Core/Src 24 | SourceFiles=; 25 | 26 | [PreviousUsedMakefileFiles] 27 | SourceFiles=Core\Src\main.c;Core\Src\stm32f1xx_it.c;Core\Src\stm32f1xx_hal_msp.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Core\Src/system_stm32f1xx.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c;Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c;Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c;Core\Src/system_stm32f1xx.c;;; 28 | HeaderPath=Drivers\STM32F1xx_HAL_Driver\Inc;Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;Drivers\CMSIS\Device\ST\STM32F1xx\Include;Drivers\CMSIS\Include;Core\Inc; 29 | CDefines=USE_HAL_DRIVER;STM32F103xE;USE_HAL_DRIVER;USE_HAL_DRIVER; 30 | 31 | -------------------------------------------------------------------------------- /CI/perf_counter_template_gcc/Core/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under BSD 3-Clause license, 14 | * the "License"; You may not use this file except in compliance with the 15 | * License. You may obtain a copy of the License at: 16 | * opensource.org/licenses/BSD-3-Clause 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __MAIN_H 24 | #define __MAIN_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f1xx_hal.h" 32 | 33 | /* Private includes ----------------------------------------------------------*/ 34 | /* USER CODE BEGIN Includes */ 35 | 36 | /* USER CODE END Includes */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* USER CODE BEGIN ET */ 40 | 41 | /* USER CODE END ET */ 42 | 43 | /* Exported constants --------------------------------------------------------*/ 44 | /* USER CODE BEGIN EC */ 45 | 46 | /* USER CODE END EC */ 47 | 48 | /* Exported macro ------------------------------------------------------------*/ 49 | /* USER CODE BEGIN EM */ 50 | 51 | /* USER CODE END EM */ 52 | 53 | /* Exported functions prototypes ---------------------------------------------*/ 54 | void Error_Handler(void); 55 | 56 | /* USER CODE BEGIN EFP */ 57 | 58 | /* USER CODE END EFP */ 59 | 60 | /* Private defines -----------------------------------------------------------*/ 61 | /* USER CODE BEGIN Private defines */ 62 | 63 | /* USER CODE END Private defines */ 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif /* __MAIN_H */ 70 | 71 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 72 | -------------------------------------------------------------------------------- /CI/perf_counter_template_gcc/Core/Inc/stm32f1xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f1xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2022 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F1xx_IT_H 23 | #define __STM32F1xx_IT_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Private includes ----------------------------------------------------------*/ 30 | /* USER CODE BEGIN Includes */ 31 | 32 | /* USER CODE END Includes */ 33 | 34 | /* Exported types ------------------------------------------------------------*/ 35 | /* USER CODE BEGIN ET */ 36 | 37 | /* USER CODE END ET */ 38 | 39 | /* Exported constants --------------------------------------------------------*/ 40 | /* USER CODE BEGIN EC */ 41 | 42 | /* USER CODE END EC */ 43 | 44 | /* Exported macro ------------------------------------------------------------*/ 45 | /* USER CODE BEGIN EM */ 46 | 47 | /* USER CODE END EM */ 48 | 49 | /* Exported functions prototypes ---------------------------------------------*/ 50 | void NMI_Handler(void); 51 | void HardFault_Handler(void); 52 | void MemManage_Handler(void); 53 | void BusFault_Handler(void); 54 | void UsageFault_Handler(void); 55 | void SVC_Handler(void); 56 | void DebugMon_Handler(void); 57 | void PendSV_Handler(void); 58 | void SysTick_Handler(void); 59 | /* USER CODE BEGIN EFP */ 60 | 61 | /* USER CODE END EFP */ 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif /* __STM32F1xx_IT_H */ 68 | 69 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 70 | -------------------------------------------------------------------------------- /CI/perf_counter_template_gcc/Core/Src/stm32f1xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f1xx_hal_msp.c 5 | * @brief This file provides code for the MSP Initialization 6 | * and de-Initialization codes. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under BSD 3-Clause license, 14 | * the "License"; You may not use this file except in compliance with the 15 | * License. You may obtain a copy of the License at: 16 | * opensource.org/licenses/BSD-3-Clause 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "main.h" 24 | /* USER CODE BEGIN Includes */ 25 | 26 | /* USER CODE END Includes */ 27 | 28 | /* Private typedef -----------------------------------------------------------*/ 29 | /* USER CODE BEGIN TD */ 30 | 31 | /* USER CODE END TD */ 32 | 33 | /* Private define ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN Define */ 35 | 36 | /* USER CODE END Define */ 37 | 38 | /* Private macro -------------------------------------------------------------*/ 39 | /* USER CODE BEGIN Macro */ 40 | 41 | /* USER CODE END Macro */ 42 | 43 | /* Private variables ---------------------------------------------------------*/ 44 | /* USER CODE BEGIN PV */ 45 | 46 | /* USER CODE END PV */ 47 | 48 | /* Private function prototypes -----------------------------------------------*/ 49 | /* USER CODE BEGIN PFP */ 50 | 51 | /* USER CODE END PFP */ 52 | 53 | /* External functions --------------------------------------------------------*/ 54 | /* USER CODE BEGIN ExternalFunctions */ 55 | 56 | /* USER CODE END ExternalFunctions */ 57 | 58 | /* USER CODE BEGIN 0 */ 59 | 60 | /* USER CODE END 0 */ 61 | /** 62 | * Initializes the Global MSP. 63 | */ 64 | void HAL_MspInit(void) 65 | { 66 | /* USER CODE BEGIN MspInit 0 */ 67 | 68 | /* USER CODE END MspInit 0 */ 69 | 70 | __HAL_RCC_AFIO_CLK_ENABLE(); 71 | __HAL_RCC_PWR_CLK_ENABLE(); 72 | 73 | /* System interrupt init*/ 74 | 75 | /** DISABLE: JTAG-DP Disabled and SW-DP Disabled 76 | */ 77 | __HAL_AFIO_REMAP_SWJ_DISABLE(); 78 | 79 | /* USER CODE BEGIN MspInit 1 */ 80 | 81 | /* USER CODE END MspInit 1 */ 82 | } 83 | 84 | /* USER CODE BEGIN 1 */ 85 | 86 | /* USER CODE END 1 */ 87 | 88 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 89 | -------------------------------------------------------------------------------- /CI/perf_counter_template_gcc/Core/Src/stm32f1xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f1xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2022 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | #include "stm32f1xx_it.h" 24 | /* Private includes ----------------------------------------------------------*/ 25 | /* USER CODE BEGIN Includes */ 26 | /* USER CODE END Includes */ 27 | 28 | /* Private typedef -----------------------------------------------------------*/ 29 | /* USER CODE BEGIN TD */ 30 | 31 | /* USER CODE END TD */ 32 | 33 | /* Private define ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN PD */ 35 | 36 | /* USER CODE END PD */ 37 | 38 | /* Private macro -------------------------------------------------------------*/ 39 | /* USER CODE BEGIN PM */ 40 | 41 | /* USER CODE END PM */ 42 | 43 | /* Private variables ---------------------------------------------------------*/ 44 | /* USER CODE BEGIN PV */ 45 | 46 | /* USER CODE END PV */ 47 | 48 | /* Private function prototypes -----------------------------------------------*/ 49 | /* USER CODE BEGIN PFP */ 50 | 51 | /* USER CODE END PFP */ 52 | 53 | /* Private user code ---------------------------------------------------------*/ 54 | /* USER CODE BEGIN 0 */ 55 | 56 | /* USER CODE END 0 */ 57 | 58 | /* External variables --------------------------------------------------------*/ 59 | 60 | /* USER CODE BEGIN EV */ 61 | 62 | /* USER CODE END EV */ 63 | 64 | /******************************************************************************/ 65 | /* Cortex-M3 Processor Interruption and Exception Handlers */ 66 | /******************************************************************************/ 67 | /** 68 | * @brief This function handles Non maskable interrupt. 69 | */ 70 | void NMI_Handler(void) 71 | { 72 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 73 | 74 | /* USER CODE END NonMaskableInt_IRQn 0 */ 75 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 76 | while (1) 77 | { 78 | } 79 | /* USER CODE END NonMaskableInt_IRQn 1 */ 80 | } 81 | 82 | /** 83 | * @brief This function handles Hard fault interrupt. 84 | */ 85 | void HardFault_Handler(void) 86 | { 87 | /* USER CODE BEGIN HardFault_IRQn 0 */ 88 | 89 | /* USER CODE END HardFault_IRQn 0 */ 90 | while (1) 91 | { 92 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */ 93 | /* USER CODE END W1_HardFault_IRQn 0 */ 94 | } 95 | } 96 | 97 | /** 98 | * @brief This function handles Memory management fault. 99 | */ 100 | void MemManage_Handler(void) 101 | { 102 | /* USER CODE BEGIN MemoryManagement_IRQn 0 */ 103 | 104 | /* USER CODE END MemoryManagement_IRQn 0 */ 105 | while (1) 106 | { 107 | /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ 108 | /* USER CODE END W1_MemoryManagement_IRQn 0 */ 109 | } 110 | } 111 | 112 | /** 113 | * @brief This function handles Prefetch fault, memory access fault. 114 | */ 115 | void BusFault_Handler(void) 116 | { 117 | /* USER CODE BEGIN BusFault_IRQn 0 */ 118 | 119 | /* USER CODE END BusFault_IRQn 0 */ 120 | while (1) 121 | { 122 | /* USER CODE BEGIN W1_BusFault_IRQn 0 */ 123 | /* USER CODE END W1_BusFault_IRQn 0 */ 124 | } 125 | } 126 | 127 | /** 128 | * @brief This function handles Undefined instruction or illegal state. 129 | */ 130 | void UsageFault_Handler(void) 131 | { 132 | /* USER CODE BEGIN UsageFault_IRQn 0 */ 133 | 134 | /* USER CODE END UsageFault_IRQn 0 */ 135 | while (1) 136 | { 137 | /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ 138 | /* USER CODE END W1_UsageFault_IRQn 0 */ 139 | } 140 | } 141 | 142 | /** 143 | * @brief This function handles System service call via SWI instruction. 144 | */ 145 | void SVC_Handler(void) 146 | { 147 | /* USER CODE BEGIN SVCall_IRQn 0 */ 148 | 149 | /* USER CODE END SVCall_IRQn 0 */ 150 | /* USER CODE BEGIN SVCall_IRQn 1 */ 151 | 152 | /* USER CODE END SVCall_IRQn 1 */ 153 | } 154 | 155 | /** 156 | * @brief This function handles Debug monitor. 157 | */ 158 | void DebugMon_Handler(void) 159 | { 160 | /* USER CODE BEGIN DebugMonitor_IRQn 0 */ 161 | 162 | /* USER CODE END DebugMonitor_IRQn 0 */ 163 | /* USER CODE BEGIN DebugMonitor_IRQn 1 */ 164 | 165 | /* USER CODE END DebugMonitor_IRQn 1 */ 166 | } 167 | 168 | /** 169 | * @brief This function handles Pendable request for system service. 170 | */ 171 | void PendSV_Handler(void) 172 | { 173 | /* USER CODE BEGIN PendSV_IRQn 0 */ 174 | 175 | /* USER CODE END PendSV_IRQn 0 */ 176 | /* USER CODE BEGIN PendSV_IRQn 1 */ 177 | 178 | /* USER CODE END PendSV_IRQn 1 */ 179 | } 180 | 181 | /** 182 | * @brief This function handles System tick timer. 183 | */ 184 | //void SysTick_Handler(void) 185 | //{ 186 | // /* USER CODE BEGIN SysTick_IRQn 0 */ 187 | 188 | // /* USER CODE END SysTick_IRQn 0 */ 189 | // HAL_IncTick(); 190 | // /* USER CODE BEGIN SysTick_IRQn 1 */ 191 | 192 | // /* USER CODE END SysTick_IRQn 1 */ 193 | //} 194 | 195 | /******************************************************************************/ 196 | /* STM32F1xx Peripheral Interrupt Handlers */ 197 | /* Add here the Interrupt Handlers for the used peripherals. */ 198 | /* For the available peripheral interrupt handler names, */ 199 | /* please refer to the startup file (startup_stm32f1xx.s). */ 200 | /******************************************************************************/ 201 | 202 | /* USER CODE BEGIN 1 */ 203 | 204 | /* USER CODE END 1 */ 205 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 206 | -------------------------------------------------------------------------------- /CI/perf_counter_template_gcc/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xe.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GorgonMeducer/perf_counter/3dfee7d3f4b201b7b857fb1445800b251d9f27e5/CI/perf_counter_template_gcc/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xe.h -------------------------------------------------------------------------------- /CI/perf_counter_template_gcc/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GorgonMeducer/perf_counter/3dfee7d3f4b201b7b857fb1445800b251d9f27e5/CI/perf_counter_template_gcc/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h -------------------------------------------------------------------------------- /CI/perf_counter_template_gcc/Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f10x.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /** @addtogroup CMSIS 21 | * @{ 22 | */ 23 | 24 | /** @addtogroup stm32f10x_system 25 | * @{ 26 | */ 27 | 28 | /** 29 | * @brief Define to prevent recursive inclusion 30 | */ 31 | #ifndef __SYSTEM_STM32F10X_H 32 | #define __SYSTEM_STM32F10X_H 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /** @addtogroup STM32F10x_System_Includes 39 | * @{ 40 | */ 41 | 42 | /** 43 | * @} 44 | */ 45 | 46 | 47 | /** @addtogroup STM32F10x_System_Exported_types 48 | * @{ 49 | */ 50 | 51 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 52 | extern const uint8_t AHBPrescTable[16U]; /*!< AHB prescalers table values */ 53 | extern const uint8_t APBPrescTable[8U]; /*!< APB prescalers table values */ 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /** @addtogroup STM32F10x_System_Exported_Constants 60 | * @{ 61 | */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @addtogroup STM32F10x_System_Exported_Macros 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32F10x_System_Exported_Functions 76 | * @{ 77 | */ 78 | 79 | extern void SystemInit(void); 80 | extern void SystemCoreClockUpdate(void); 81 | /** 82 | * @} 83 | */ 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif /*__SYSTEM_STM32F10X_H */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 99 | -------------------------------------------------------------------------------- /CI/perf_counter_template_gcc/Drivers/CMSIS/Include/cmsis_compiler.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_compiler.h 3 | * @brief CMSIS compiler generic header file 4 | * @version V5.0.4 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2018 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #ifndef __CMSIS_COMPILER_H 26 | #define __CMSIS_COMPILER_H 27 | 28 | #include 29 | 30 | /* 31 | * Arm Compiler 4/5 32 | */ 33 | #if defined ( __CC_ARM ) 34 | #include "cmsis_armcc.h" 35 | 36 | 37 | /* 38 | * Arm Compiler 6 (armclang) 39 | */ 40 | #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 41 | #include "cmsis_armclang.h" 42 | 43 | 44 | /* 45 | * GNU Compiler 46 | */ 47 | #elif defined ( __GNUC__ ) 48 | #include "cmsis_gcc.h" 49 | 50 | 51 | /* 52 | * IAR Compiler 53 | */ 54 | #elif defined ( __ICCARM__ ) 55 | #include 56 | 57 | 58 | /* 59 | * TI Arm Compiler 60 | */ 61 | #elif defined ( __TI_ARM__ ) 62 | #include 63 | 64 | #ifndef __ASM 65 | #define __ASM __asm 66 | #endif 67 | #ifndef __INLINE 68 | #define __INLINE inline 69 | #endif 70 | #ifndef __STATIC_INLINE 71 | #define __STATIC_INLINE static inline 72 | #endif 73 | #ifndef __STATIC_FORCEINLINE 74 | #define __STATIC_FORCEINLINE __STATIC_INLINE 75 | #endif 76 | #ifndef __NO_RETURN 77 | #define __NO_RETURN __attribute__((noreturn)) 78 | #endif 79 | #ifndef __USED 80 | #define __USED __attribute__((used)) 81 | #endif 82 | #ifndef __WEAK 83 | #define __WEAK __attribute__((weak)) 84 | #endif 85 | #ifndef __PACKED 86 | #define __PACKED __attribute__((packed)) 87 | #endif 88 | #ifndef __PACKED_STRUCT 89 | #define __PACKED_STRUCT struct __attribute__((packed)) 90 | #endif 91 | #ifndef __PACKED_UNION 92 | #define __PACKED_UNION union __attribute__((packed)) 93 | #endif 94 | #ifndef __UNALIGNED_UINT32 /* deprecated */ 95 | struct __attribute__((packed)) T_UINT32 { uint32_t v; }; 96 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 97 | #endif 98 | #ifndef __UNALIGNED_UINT16_WRITE 99 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 100 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val)) 101 | #endif 102 | #ifndef __UNALIGNED_UINT16_READ 103 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 104 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 105 | #endif 106 | #ifndef __UNALIGNED_UINT32_WRITE 107 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 108 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 109 | #endif 110 | #ifndef __UNALIGNED_UINT32_READ 111 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 112 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 113 | #endif 114 | #ifndef __ALIGNED 115 | #define __ALIGNED(x) __attribute__((aligned(x))) 116 | #endif 117 | #ifndef __RESTRICT 118 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 119 | #define __RESTRICT 120 | #endif 121 | 122 | 123 | /* 124 | * TASKING Compiler 125 | */ 126 | #elif defined ( __TASKING__ ) 127 | /* 128 | * The CMSIS functions have been implemented as intrinsics in the compiler. 129 | * Please use "carm -?i" to get an up to date list of all intrinsics, 130 | * Including the CMSIS ones. 131 | */ 132 | 133 | #ifndef __ASM 134 | #define __ASM __asm 135 | #endif 136 | #ifndef __INLINE 137 | #define __INLINE inline 138 | #endif 139 | #ifndef __STATIC_INLINE 140 | #define __STATIC_INLINE static inline 141 | #endif 142 | #ifndef __STATIC_FORCEINLINE 143 | #define __STATIC_FORCEINLINE __STATIC_INLINE 144 | #endif 145 | #ifndef __NO_RETURN 146 | #define __NO_RETURN __attribute__((noreturn)) 147 | #endif 148 | #ifndef __USED 149 | #define __USED __attribute__((used)) 150 | #endif 151 | #ifndef __WEAK 152 | #define __WEAK __attribute__((weak)) 153 | #endif 154 | #ifndef __PACKED 155 | #define __PACKED __packed__ 156 | #endif 157 | #ifndef __PACKED_STRUCT 158 | #define __PACKED_STRUCT struct __packed__ 159 | #endif 160 | #ifndef __PACKED_UNION 161 | #define __PACKED_UNION union __packed__ 162 | #endif 163 | #ifndef __UNALIGNED_UINT32 /* deprecated */ 164 | struct __packed__ T_UINT32 { uint32_t v; }; 165 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 166 | #endif 167 | #ifndef __UNALIGNED_UINT16_WRITE 168 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 169 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) 170 | #endif 171 | #ifndef __UNALIGNED_UINT16_READ 172 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 173 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 174 | #endif 175 | #ifndef __UNALIGNED_UINT32_WRITE 176 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 177 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 178 | #endif 179 | #ifndef __UNALIGNED_UINT32_READ 180 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 181 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 182 | #endif 183 | #ifndef __ALIGNED 184 | #define __ALIGNED(x) __align(x) 185 | #endif 186 | #ifndef __RESTRICT 187 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 188 | #define __RESTRICT 189 | #endif 190 | 191 | 192 | /* 193 | * COSMIC Compiler 194 | */ 195 | #elif defined ( __CSMC__ ) 196 | #include 197 | 198 | #ifndef __ASM 199 | #define __ASM _asm 200 | #endif 201 | #ifndef __INLINE 202 | #define __INLINE inline 203 | #endif 204 | #ifndef __STATIC_INLINE 205 | #define __STATIC_INLINE static inline 206 | #endif 207 | #ifndef __STATIC_FORCEINLINE 208 | #define __STATIC_FORCEINLINE __STATIC_INLINE 209 | #endif 210 | #ifndef __NO_RETURN 211 | // NO RETURN is automatically detected hence no warning here 212 | #define __NO_RETURN 213 | #endif 214 | #ifndef __USED 215 | #warning No compiler specific solution for __USED. __USED is ignored. 216 | #define __USED 217 | #endif 218 | #ifndef __WEAK 219 | #define __WEAK __weak 220 | #endif 221 | #ifndef __PACKED 222 | #define __PACKED @packed 223 | #endif 224 | #ifndef __PACKED_STRUCT 225 | #define __PACKED_STRUCT @packed struct 226 | #endif 227 | #ifndef __PACKED_UNION 228 | #define __PACKED_UNION @packed union 229 | #endif 230 | #ifndef __UNALIGNED_UINT32 /* deprecated */ 231 | @packed struct T_UINT32 { uint32_t v; }; 232 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) 233 | #endif 234 | #ifndef __UNALIGNED_UINT16_WRITE 235 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; 236 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) 237 | #endif 238 | #ifndef __UNALIGNED_UINT16_READ 239 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; 240 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) 241 | #endif 242 | #ifndef __UNALIGNED_UINT32_WRITE 243 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; 244 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) 245 | #endif 246 | #ifndef __UNALIGNED_UINT32_READ 247 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; 248 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) 249 | #endif 250 | #ifndef __ALIGNED 251 | #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored. 252 | #define __ALIGNED(x) 253 | #endif 254 | #ifndef __RESTRICT 255 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. 256 | #define __RESTRICT 257 | #endif 258 | 259 | 260 | #else 261 | #error Unknown compiler. 262 | #endif 263 | 264 | 265 | #endif /* __CMSIS_COMPILER_H */ 266 | 267 | -------------------------------------------------------------------------------- /CI/perf_counter_template_gcc/Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.2 5 | * @date 19. April 2017 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /CI/perf_counter_template_gcc/Drivers/CMSIS/Include/tz_context.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file tz_context.h 3 | * @brief Context Management for Armv8-M TrustZone 4 | * @version V1.0.1 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef TZ_CONTEXT_H 32 | #define TZ_CONTEXT_H 33 | 34 | #include 35 | 36 | #ifndef TZ_MODULEID_T 37 | #define TZ_MODULEID_T 38 | /// \details Data type that identifies secure software modules called by a process. 39 | typedef uint32_t TZ_ModuleId_t; 40 | #endif 41 | 42 | /// \details TZ Memory ID identifies an allocated memory slot. 43 | typedef uint32_t TZ_MemoryId_t; 44 | 45 | /// Initialize secure context memory system 46 | /// \return execution status (1: success, 0: error) 47 | uint32_t TZ_InitContextSystem_S (void); 48 | 49 | /// Allocate context memory for calling secure software modules in TrustZone 50 | /// \param[in] module identifies software modules called from non-secure mode 51 | /// \return value != 0 id TrustZone memory slot identifier 52 | /// \return value 0 no memory available or internal error 53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); 54 | 55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S 56 | /// \param[in] id TrustZone memory slot identifier 57 | /// \return execution status (1: success, 0: error) 58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); 59 | 60 | /// Load secure context (called on RTOS thread context switch) 61 | /// \param[in] id TrustZone memory slot identifier 62 | /// \return execution status (1: success, 0: error) 63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); 64 | 65 | /// Store secure context (called on RTOS thread context switch) 66 | /// \param[in] id TrustZone memory slot identifier 67 | /// \return execution status (1: success, 0: error) 68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); 69 | 70 | #endif // TZ_CONTEXT_H 71 | -------------------------------------------------------------------------------- /CI/perf_counter_template_gcc/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_def.h 4 | * @author MCD Application Team 5 | * @brief This file contains HAL common defines, enumeration, macros and 6 | * structures definitions. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2017 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under BSD 3-Clause license, 14 | * the "License"; You may not use this file except in compliance with the 15 | * License. You may obtain a copy of the License at: 16 | * opensource.org/licenses/BSD-3-Clause 17 | * 18 | ****************************************************************************** 19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F1xx_HAL_DEF 23 | #define __STM32F1xx_HAL_DEF 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32f1xx.h" 31 | #include "Legacy/stm32_hal_legacy.h" 32 | #include 33 | 34 | /* Exported types ------------------------------------------------------------*/ 35 | 36 | /** 37 | * @brief HAL Status structures definition 38 | */ 39 | typedef enum 40 | { 41 | HAL_OK = 0x00U, 42 | HAL_ERROR = 0x01U, 43 | HAL_BUSY = 0x02U, 44 | HAL_TIMEOUT = 0x03U 45 | } HAL_StatusTypeDef; 46 | 47 | /** 48 | * @brief HAL Lock structures definition 49 | */ 50 | typedef enum 51 | { 52 | HAL_UNLOCKED = 0x00U, 53 | HAL_LOCKED = 0x01U 54 | } HAL_LockTypeDef; 55 | 56 | /* Exported macro ------------------------------------------------------------*/ 57 | #define HAL_MAX_DELAY 0xFFFFFFFFU 58 | 59 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != 0U) 60 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U) 61 | 62 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ 63 | do{ \ 64 | (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ 65 | (__DMA_HANDLE__).Parent = (__HANDLE__); \ 66 | } while(0U) 67 | 68 | #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */ 69 | 70 | /** @brief Reset the Handle's State field. 71 | * @param __HANDLE__ specifies the Peripheral Handle. 72 | * @note This macro can be used for the following purpose: 73 | * - When the Handle is declared as local variable; before passing it as parameter 74 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro 75 | * to set to 0 the Handle's "State" field. 76 | * Otherwise, "State" field may have any random value and the first time the function 77 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed 78 | * (i.e. HAL_PPP_MspInit() will not be executed). 79 | * - When there is a need to reconfigure the low level hardware: instead of calling 80 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). 81 | * In this later function, when the Handle's "State" field is set to 0, it will execute the function 82 | * HAL_PPP_MspInit() which will reconfigure the low level hardware. 83 | * @retval None 84 | */ 85 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U) 86 | 87 | #if (USE_RTOS == 1U) 88 | /* Reserved for future use */ 89 | #error "USE_RTOS should be 0 in the current HAL release" 90 | #else 91 | #define __HAL_LOCK(__HANDLE__) \ 92 | do{ \ 93 | if((__HANDLE__)->Lock == HAL_LOCKED) \ 94 | { \ 95 | return HAL_BUSY; \ 96 | } \ 97 | else \ 98 | { \ 99 | (__HANDLE__)->Lock = HAL_LOCKED; \ 100 | } \ 101 | }while (0U) 102 | 103 | #define __HAL_UNLOCK(__HANDLE__) \ 104 | do{ \ 105 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ 106 | }while (0U) 107 | #endif /* USE_RTOS */ 108 | 109 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ 110 | #ifndef __weak 111 | #define __weak __attribute__((weak)) 112 | #endif 113 | #ifndef __packed 114 | #define __packed __attribute__((packed)) 115 | #endif 116 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ 117 | #ifndef __weak 118 | #define __weak __attribute__((weak)) 119 | #endif /* __weak */ 120 | #ifndef __packed 121 | #define __packed __attribute__((__packed__)) 122 | #endif /* __packed */ 123 | #endif /* __GNUC__ */ 124 | 125 | 126 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ 127 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ 128 | #ifndef __ALIGN_BEGIN 129 | #define __ALIGN_BEGIN 130 | #endif 131 | #ifndef __ALIGN_END 132 | #define __ALIGN_END __attribute__ ((aligned (4))) 133 | #endif 134 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ 135 | #ifndef __ALIGN_END 136 | #define __ALIGN_END __attribute__ ((aligned (4))) 137 | #endif /* __ALIGN_END */ 138 | #ifndef __ALIGN_BEGIN 139 | #define __ALIGN_BEGIN 140 | #endif /* __ALIGN_BEGIN */ 141 | #else 142 | #ifndef __ALIGN_END 143 | #define __ALIGN_END 144 | #endif /* __ALIGN_END */ 145 | #ifndef __ALIGN_BEGIN 146 | #if defined (__CC_ARM) /* ARM Compiler V5*/ 147 | #define __ALIGN_BEGIN __align(4) 148 | #elif defined (__ICCARM__) /* IAR Compiler */ 149 | #define __ALIGN_BEGIN 150 | #endif /* __CC_ARM */ 151 | #endif /* __ALIGN_BEGIN */ 152 | #endif /* __GNUC__ */ 153 | 154 | 155 | /** 156 | * @brief __RAM_FUNC definition 157 | */ 158 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) 159 | /* ARM Compiler V4/V5 and V6 160 | -------------------------- 161 | RAM functions are defined using the toolchain options. 162 | Functions that are executed in RAM should reside in a separate source module. 163 | Using the 'Options for File' dialog you can simply change the 'Code / Const' 164 | area of a module to a memory space in physical RAM. 165 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' 166 | dialog. 167 | */ 168 | #define __RAM_FUNC 169 | 170 | #elif defined ( __ICCARM__ ) 171 | /* ICCARM Compiler 172 | --------------- 173 | RAM functions are defined using a specific toolchain keyword "__ramfunc". 174 | */ 175 | #define __RAM_FUNC __ramfunc 176 | 177 | #elif defined ( __GNUC__ ) 178 | /* GNU Compiler 179 | ------------ 180 | RAM functions are defined using a specific toolchain attribute 181 | "__attribute__((section(".RamFunc")))". 182 | */ 183 | #define __RAM_FUNC __attribute__((section(".RamFunc"))) 184 | 185 | #endif 186 | 187 | /** 188 | * @brief __NOINLINE definition 189 | */ 190 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined ( __GNUC__ ) 191 | /* ARM V4/V5 and V6 & GNU Compiler 192 | ------------------------------- 193 | */ 194 | #define __NOINLINE __attribute__ ( (noinline) ) 195 | 196 | #elif defined ( __ICCARM__ ) 197 | /* ICCARM Compiler 198 | --------------- 199 | */ 200 | #define __NOINLINE _Pragma("optimize = no_inline") 201 | 202 | #endif 203 | 204 | #ifdef __cplusplus 205 | } 206 | #endif 207 | 208 | #endif /* ___STM32F1xx_HAL_DEF */ 209 | 210 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 211 | -------------------------------------------------------------------------------- /CI/perf_counter_template_gcc/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_flash.h 4 | * @author MCD Application Team 5 | * @brief Header file of Flash HAL module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2016 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32F1xx_HAL_FLASH_H 22 | #define __STM32F1xx_HAL_FLASH_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f1xx_hal_def.h" 30 | 31 | /** @addtogroup STM32F1xx_HAL_Driver 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup FLASH 36 | * @{ 37 | */ 38 | 39 | /** @addtogroup FLASH_Private_Constants 40 | * @{ 41 | */ 42 | #define FLASH_TIMEOUT_VALUE 50000U /* 50 s */ 43 | /** 44 | * @} 45 | */ 46 | 47 | /** @addtogroup FLASH_Private_Macros 48 | * @{ 49 | */ 50 | 51 | #define IS_FLASH_TYPEPROGRAM(VALUE) (((VALUE) == FLASH_TYPEPROGRAM_HALFWORD) || \ 52 | ((VALUE) == FLASH_TYPEPROGRAM_WORD) || \ 53 | ((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD)) 54 | 55 | #if defined(FLASH_ACR_LATENCY) 56 | #define IS_FLASH_LATENCY(__LATENCY__) (((__LATENCY__) == FLASH_LATENCY_0) || \ 57 | ((__LATENCY__) == FLASH_LATENCY_1) || \ 58 | ((__LATENCY__) == FLASH_LATENCY_2)) 59 | 60 | #else 61 | #define IS_FLASH_LATENCY(__LATENCY__) ((__LATENCY__) == FLASH_LATENCY_0) 62 | #endif /* FLASH_ACR_LATENCY */ 63 | /** 64 | * @} 65 | */ 66 | 67 | /* Exported types ------------------------------------------------------------*/ 68 | /** @defgroup FLASH_Exported_Types FLASH Exported Types 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @brief FLASH Procedure structure definition 74 | */ 75 | typedef enum 76 | { 77 | FLASH_PROC_NONE = 0U, 78 | FLASH_PROC_PAGEERASE = 1U, 79 | FLASH_PROC_MASSERASE = 2U, 80 | FLASH_PROC_PROGRAMHALFWORD = 3U, 81 | FLASH_PROC_PROGRAMWORD = 4U, 82 | FLASH_PROC_PROGRAMDOUBLEWORD = 5U 83 | } FLASH_ProcedureTypeDef; 84 | 85 | /** 86 | * @brief FLASH handle Structure definition 87 | */ 88 | typedef struct 89 | { 90 | __IO FLASH_ProcedureTypeDef ProcedureOnGoing; /*!< Internal variable to indicate which procedure is ongoing or not in IT context */ 91 | 92 | __IO uint32_t DataRemaining; /*!< Internal variable to save the remaining pages to erase or half-word to program in IT context */ 93 | 94 | __IO uint32_t Address; /*!< Internal variable to save address selected for program or erase */ 95 | 96 | __IO uint64_t Data; /*!< Internal variable to save data to be programmed */ 97 | 98 | HAL_LockTypeDef Lock; /*!< FLASH locking object */ 99 | 100 | __IO uint32_t ErrorCode; /*!< FLASH error code 101 | This parameter can be a value of @ref FLASH_Error_Codes */ 102 | } FLASH_ProcessTypeDef; 103 | 104 | /** 105 | * @} 106 | */ 107 | 108 | /* Exported constants --------------------------------------------------------*/ 109 | /** @defgroup FLASH_Exported_Constants FLASH Exported Constants 110 | * @{ 111 | */ 112 | 113 | /** @defgroup FLASH_Error_Codes FLASH Error Codes 114 | * @{ 115 | */ 116 | 117 | #define HAL_FLASH_ERROR_NONE 0x00U /*!< No error */ 118 | #define HAL_FLASH_ERROR_PROG 0x01U /*!< Programming error */ 119 | #define HAL_FLASH_ERROR_WRP 0x02U /*!< Write protection error */ 120 | #define HAL_FLASH_ERROR_OPTV 0x04U /*!< Option validity error */ 121 | 122 | /** 123 | * @} 124 | */ 125 | 126 | /** @defgroup FLASH_Type_Program FLASH Type Program 127 | * @{ 128 | */ 129 | #define FLASH_TYPEPROGRAM_HALFWORD 0x01U /*!ACR |= FLASH_ACR_HLFCYA) 183 | 184 | /** 185 | * @brief Disable the FLASH half cycle access. 186 | * @note half cycle access can only be used with a low-frequency clock of less than 187 | 8 MHz that can be obtained with the use of HSI or HSE but not of PLL. 188 | * @retval None 189 | */ 190 | #define __HAL_FLASH_HALF_CYCLE_ACCESS_DISABLE() (FLASH->ACR &= (~FLASH_ACR_HLFCYA)) 191 | 192 | /** 193 | * @} 194 | */ 195 | 196 | #if defined(FLASH_ACR_LATENCY) 197 | /** @defgroup FLASH_EM_Latency FLASH Latency 198 | * @brief macros to handle FLASH Latency 199 | * @{ 200 | */ 201 | 202 | /** 203 | * @brief Set the FLASH Latency. 204 | * @param __LATENCY__ FLASH Latency 205 | * The value of this parameter depend on device used within the same series 206 | * @retval None 207 | */ 208 | #define __HAL_FLASH_SET_LATENCY(__LATENCY__) (FLASH->ACR = (FLASH->ACR&(~FLASH_ACR_LATENCY)) | (__LATENCY__)) 209 | 210 | 211 | /** 212 | * @brief Get the FLASH Latency. 213 | * @retval FLASH Latency 214 | * The value of this parameter depend on device used within the same series 215 | */ 216 | #define __HAL_FLASH_GET_LATENCY() (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)) 217 | 218 | /** 219 | * @} 220 | */ 221 | 222 | #endif /* FLASH_ACR_LATENCY */ 223 | /** @defgroup FLASH_Prefetch FLASH Prefetch 224 | * @brief macros to handle FLASH Prefetch buffer 225 | * @{ 226 | */ 227 | /** 228 | * @brief Enable the FLASH prefetch buffer. 229 | * @retval None 230 | */ 231 | #define __HAL_FLASH_PREFETCH_BUFFER_ENABLE() (FLASH->ACR |= FLASH_ACR_PRFTBE) 232 | 233 | /** 234 | * @brief Disable the FLASH prefetch buffer. 235 | * @retval None 236 | */ 237 | #define __HAL_FLASH_PREFETCH_BUFFER_DISABLE() (FLASH->ACR &= (~FLASH_ACR_PRFTBE)) 238 | 239 | /** 240 | * @} 241 | */ 242 | 243 | /** 244 | * @} 245 | */ 246 | 247 | /* Include FLASH HAL Extended module */ 248 | #include "stm32f1xx_hal_flash_ex.h" 249 | 250 | /* Exported functions --------------------------------------------------------*/ 251 | /** @addtogroup FLASH_Exported_Functions 252 | * @{ 253 | */ 254 | 255 | /** @addtogroup FLASH_Exported_Functions_Group1 256 | * @{ 257 | */ 258 | /* IO operation functions *****************************************************/ 259 | HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data); 260 | HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data); 261 | 262 | /* FLASH IRQ handler function */ 263 | void HAL_FLASH_IRQHandler(void); 264 | /* Callbacks in non blocking modes */ 265 | void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue); 266 | void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue); 267 | 268 | /** 269 | * @} 270 | */ 271 | 272 | /** @addtogroup FLASH_Exported_Functions_Group2 273 | * @{ 274 | */ 275 | /* Peripheral Control functions ***********************************************/ 276 | HAL_StatusTypeDef HAL_FLASH_Unlock(void); 277 | HAL_StatusTypeDef HAL_FLASH_Lock(void); 278 | HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void); 279 | HAL_StatusTypeDef HAL_FLASH_OB_Lock(void); 280 | void HAL_FLASH_OB_Launch(void); 281 | 282 | /** 283 | * @} 284 | */ 285 | 286 | /** @addtogroup FLASH_Exported_Functions_Group3 287 | * @{ 288 | */ 289 | /* Peripheral State and Error functions ***************************************/ 290 | uint32_t HAL_FLASH_GetError(void); 291 | 292 | /** 293 | * @} 294 | */ 295 | 296 | /** 297 | * @} 298 | */ 299 | 300 | /* Private function -------------------------------------------------*/ 301 | /** @addtogroup FLASH_Private_Functions 302 | * @{ 303 | */ 304 | HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout); 305 | #if defined(FLASH_BANK2_END) 306 | HAL_StatusTypeDef FLASH_WaitForLastOperationBank2(uint32_t Timeout); 307 | #endif /* FLASH_BANK2_END */ 308 | 309 | /** 310 | * @} 311 | */ 312 | 313 | /** 314 | * @} 315 | */ 316 | 317 | /** 318 | * @} 319 | */ 320 | 321 | #ifdef __cplusplus 322 | } 323 | #endif 324 | 325 | #endif /* __STM32F1xx_HAL_FLASH_H */ 326 | 327 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 328 | 329 | -------------------------------------------------------------------------------- /CI/perf_counter_template_gcc/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f1xx_hal_gpio_ex.c 4 | * @author MCD Application Team 5 | * @brief GPIO Extension HAL module driver. 6 | * This file provides firmware functions to manage the following 7 | * functionalities of the General Purpose Input/Output (GPIO) extension peripheral. 8 | * + Extended features functions 9 | * 10 | @verbatim 11 | ============================================================================== 12 | ##### GPIO Peripheral extension features ##### 13 | ============================================================================== 14 | [..] GPIO module on STM32F1 family, manage also the AFIO register: 15 | (+) Possibility to use the EVENTOUT Cortex feature 16 | 17 | ##### How to use this driver ##### 18 | ============================================================================== 19 | [..] This driver provides functions to use EVENTOUT Cortex feature 20 | (#) Configure EVENTOUT Cortex feature using the function HAL_GPIOEx_ConfigEventout() 21 | (#) Activate EVENTOUT Cortex feature using the HAL_GPIOEx_EnableEventout() 22 | (#) Deactivate EVENTOUT Cortex feature using the HAL_GPIOEx_DisableEventout() 23 | 24 | @endverbatim 25 | ****************************************************************************** 26 | * @attention 27 | * 28 | *

© Copyright (c) 2016 STMicroelectronics. 29 | * All rights reserved.

30 | * 31 | * This software component is licensed by ST under BSD 3-Clause license, 32 | * the "License"; You may not use this file except in compliance with the 33 | * License. You may obtain a copy of the License at: 34 | * opensource.org/licenses/BSD-3-Clause 35 | * 36 | ****************************************************************************** 37 | */ 38 | 39 | /* Includes ------------------------------------------------------------------*/ 40 | #include "stm32f1xx_hal.h" 41 | 42 | /** @addtogroup STM32F1xx_HAL_Driver 43 | * @{ 44 | */ 45 | 46 | /** @defgroup GPIOEx GPIOEx 47 | * @brief GPIO HAL module driver 48 | * @{ 49 | */ 50 | 51 | #ifdef HAL_GPIO_MODULE_ENABLED 52 | 53 | /** @defgroup GPIOEx_Exported_Functions GPIOEx Exported Functions 54 | * @{ 55 | */ 56 | 57 | /** @defgroup GPIOEx_Exported_Functions_Group1 Extended features functions 58 | * @brief Extended features functions 59 | * 60 | @verbatim 61 | ============================================================================== 62 | ##### Extended features functions ##### 63 | ============================================================================== 64 | [..] This section provides functions allowing to: 65 | (+) Configure EVENTOUT Cortex feature using the function HAL_GPIOEx_ConfigEventout() 66 | (+) Activate EVENTOUT Cortex feature using the HAL_GPIOEx_EnableEventout() 67 | (+) Deactivate EVENTOUT Cortex feature using the HAL_GPIOEx_DisableEventout() 68 | 69 | @endverbatim 70 | * @{ 71 | */ 72 | 73 | /** 74 | * @brief Configures the port and pin on which the EVENTOUT Cortex signal will be connected. 75 | * @param GPIO_PortSource Select the port used to output the Cortex EVENTOUT signal. 76 | * This parameter can be a value of @ref GPIOEx_EVENTOUT_PORT. 77 | * @param GPIO_PinSource Select the pin used to output the Cortex EVENTOUT signal. 78 | * This parameter can be a value of @ref GPIOEx_EVENTOUT_PIN. 79 | * @retval None 80 | */ 81 | void HAL_GPIOEx_ConfigEventout(uint32_t GPIO_PortSource, uint32_t GPIO_PinSource) 82 | { 83 | /* Verify the parameters */ 84 | assert_param(IS_AFIO_EVENTOUT_PORT(GPIO_PortSource)); 85 | assert_param(IS_AFIO_EVENTOUT_PIN(GPIO_PinSource)); 86 | 87 | /* Apply the new configuration */ 88 | MODIFY_REG(AFIO->EVCR, (AFIO_EVCR_PORT) | (AFIO_EVCR_PIN), (GPIO_PortSource) | (GPIO_PinSource)); 89 | } 90 | 91 | /** 92 | * @brief Enables the Event Output. 93 | * @retval None 94 | */ 95 | void HAL_GPIOEx_EnableEventout(void) 96 | { 97 | SET_BIT(AFIO->EVCR, AFIO_EVCR_EVOE); 98 | } 99 | 100 | /** 101 | * @brief Disables the Event Output. 102 | * @retval None 103 | */ 104 | void HAL_GPIOEx_DisableEventout(void) 105 | { 106 | CLEAR_BIT(AFIO->EVCR, AFIO_EVCR_EVOE); 107 | } 108 | 109 | /** 110 | * @} 111 | */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | #endif /* HAL_GPIO_MODULE_ENABLED */ 118 | 119 | /** 120 | * @} 121 | */ 122 | 123 | /** 124 | * @} 125 | */ 126 | 127 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 128 | -------------------------------------------------------------------------------- /CI/perf_counter_template_gcc/Makefile: -------------------------------------------------------------------------------- 1 | ########################################################################################################################## 2 | # File automatically-generated by tool: [projectgenerator] version: [3.14.1] date: [Mon Jan 03 17:01:21 CST 2022] 3 | ########################################################################################################################## 4 | 5 | # ------------------------------------------------ 6 | # Generic Makefile (based on gcc) 7 | # 8 | # ChangeLog : 9 | # 2017-02-10 - Several enhancements + project update mode 10 | # 2015-07-22 - first version 11 | # ------------------------------------------------ 12 | 13 | ###################################### 14 | # target 15 | ###################################### 16 | TARGET = perf_counter_template_gcc 17 | 18 | 19 | ###################################### 20 | # building variables 21 | ###################################### 22 | # debug build? 23 | DEBUG = 1 24 | # optimization 25 | OPT = -Og 26 | 27 | 28 | ####################################### 29 | # paths 30 | ####################################### 31 | # Build path 32 | BUILD_DIR = build 33 | 34 | ###################################### 35 | # source 36 | ###################################### 37 | # C sources 38 | C_SOURCES = \ 39 | Core/Src/stm32f1xx_it.c \ 40 | Core/Src/stm32f1xx_hal_msp.c \ 41 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c \ 42 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c \ 43 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c \ 44 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c \ 45 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c \ 46 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c \ 47 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c \ 48 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c \ 49 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c \ 50 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c \ 51 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c \ 52 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c \ 53 | Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c \ 54 | platform.c \ 55 | ../../example/main.c \ 56 | ../../example/stdout_USART.c \ 57 | ../../perf_counter.c \ 58 | Core/Src/system_stm32f1xx.c 59 | 60 | # ASM sources 61 | ASM_SOURCES = \ 62 | startup_stm32f103xe.s \ 63 | ../../systick_wrapper_gcc.s 64 | 65 | 66 | ####################################### 67 | # binaries 68 | ####################################### 69 | PREFIX = arm-none-eabi- 70 | # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx) 71 | # either it can be added to the PATH environment variable. 72 | ifdef GCC_PATH 73 | CC = $(GCC_PATH)/$(PREFIX)gcc 74 | AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp 75 | CP = $(GCC_PATH)/$(PREFIX)objcopy 76 | SZ = $(GCC_PATH)/$(PREFIX)size 77 | else 78 | CC = $(PREFIX)gcc 79 | AS = $(PREFIX)gcc -x assembler-with-cpp 80 | CP = $(PREFIX)objcopy 81 | SZ = $(PREFIX)size 82 | endif 83 | HEX = $(CP) -O ihex 84 | BIN = $(CP) -O binary -S 85 | 86 | ####################################### 87 | # CFLAGS 88 | ####################################### 89 | # cpu 90 | CPU = -mcpu=cortex-m3 91 | 92 | # fpu 93 | # NONE for Cortex-M0/M0+/M3 94 | 95 | # float-abi 96 | 97 | 98 | # mcu 99 | MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI) 100 | 101 | # macros for gcc 102 | # AS defines 103 | AS_DEFS = 104 | 105 | # C defines 106 | C_DEFS = \ 107 | -DUSE_HAL_DRIVER \ 108 | -DSTM32F103xE 109 | 110 | 111 | # AS includes 112 | AS_INCLUDES = 113 | 114 | # C includes 115 | C_INCLUDES = \ 116 | -ICore/Inc \ 117 | -IDrivers/STM32F1xx_HAL_Driver/Inc \ 118 | -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \ 119 | -IDrivers/CMSIS/Device/ST/STM32F1xx/Include \ 120 | -I../../example \ 121 | -I../.. \ 122 | -IDrivers/CMSIS/Include 123 | 124 | 125 | # compile gcc flags 126 | ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections 127 | 128 | CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections 129 | 130 | ifeq ($(DEBUG), 1) 131 | CFLAGS += -g -gdwarf-2 132 | endif 133 | 134 | 135 | # Generate dependency information 136 | CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" 137 | 138 | 139 | ####################################### 140 | # LDFLAGS 141 | ####################################### 142 | # link script 143 | LDSCRIPT = STM32F103RCTx_FLASH.ld 144 | 145 | # libraries 146 | LIBS = -lc -lm -lnosys 147 | LIBDIR = 148 | LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections -Wl,--wrap=SysTick_Handler 149 | 150 | # default action: build all 151 | all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin 152 | 153 | 154 | ####################################### 155 | # build the application 156 | ####################################### 157 | # list of objects 158 | OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) 159 | vpath %.c $(sort $(dir $(C_SOURCES))) 160 | # list of ASM program objects 161 | OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) 162 | vpath %.s $(sort $(dir $(ASM_SOURCES))) 163 | 164 | $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 165 | $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ 166 | 167 | $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) 168 | $(AS) -c $(CFLAGS) $< -o $@ 169 | 170 | $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile 171 | $(CC) $(OBJECTS) $(LDFLAGS) -o $@ 172 | $(SZ) $@ 173 | 174 | $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) 175 | $(HEX) $< $@ 176 | 177 | $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) 178 | $(BIN) $< $@ 179 | 180 | $(BUILD_DIR): 181 | mkdir $@ 182 | 183 | ####################################### 184 | # clean up 185 | ####################################### 186 | clean: 187 | -rm -fR $(BUILD_DIR) 188 | 189 | ####################################### 190 | # dependencies 191 | ####################################### 192 | -include $(wildcard $(BUILD_DIR)/*.d) 193 | 194 | # *** EOF *** -------------------------------------------------------------------------------- /CI/perf_counter_template_gcc/STM32F103RCTx_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | 5 | ** File : LinkerScript.ld 6 | ** 7 | ** Author : Auto-generated by System Workbench for STM32 8 | ** 9 | ** Abstract : Linker script for STM32F103RCTx series 10 | ** 256Kbytes FLASH and 48Kbytes RAM 11 | ** 12 | ** Set heap size, stack size and stack location according 13 | ** to application requirements. 14 | ** 15 | ** Set memory bank area and size if external memory is used. 16 | ** 17 | ** Target : STMicroelectronics STM32 18 | ** 19 | ** Distribution: The file is distributed “as is,” without any warranty 20 | ** of any kind. 21 | ** 22 | ***************************************************************************** 23 | ** @attention 24 | ** 25 | **

© COPYRIGHT(c) 2019 STMicroelectronics

26 | ** 27 | ** Redistribution and use in source and binary forms, with or without modification, 28 | ** are permitted provided that the following conditions are met: 29 | ** 1. Redistributions of source code must retain the above copyright notice, 30 | ** this list of conditions and the following disclaimer. 31 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 32 | ** this list of conditions and the following disclaimer in the documentation 33 | ** and/or other materials provided with the distribution. 34 | ** 3. Neither the name of STMicroelectronics nor the names of its contributors 35 | ** may be used to endorse or promote products derived from this software 36 | ** without specific prior written permission. 37 | ** 38 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 41 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 42 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 43 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 44 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 45 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 47 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | ** 49 | ***************************************************************************** 50 | */ 51 | 52 | /* Entry Point */ 53 | ENTRY(Reset_Handler) 54 | 55 | /* Highest address of the user mode stack */ 56 | _estack = 0x2000C000; /* end of RAM */ 57 | /* Generate a link error if heap and stack don't fit into RAM */ 58 | _Min_Heap_Size = 0x200; /* required amount of heap */ 59 | _Min_Stack_Size = 0x400; /* required amount of stack */ 60 | 61 | /* Specify the memory areas */ 62 | MEMORY 63 | { 64 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K 65 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 256K 66 | } 67 | 68 | /* Define output sections */ 69 | SECTIONS 70 | { 71 | /* The startup code goes first into FLASH */ 72 | .isr_vector : 73 | { 74 | . = ALIGN(4); 75 | KEEP(*(.isr_vector)) /* Startup code */ 76 | . = ALIGN(4); 77 | } >FLASH 78 | 79 | /* The program code and other data goes into FLASH */ 80 | .text : 81 | { 82 | . = ALIGN(4); 83 | *(.text) /* .text sections (code) */ 84 | *(.text*) /* .text* sections (code) */ 85 | *(.glue_7) /* glue arm to thumb code */ 86 | *(.glue_7t) /* glue thumb to arm code */ 87 | *(.eh_frame) 88 | 89 | KEEP (*(.init)) 90 | KEEP (*(.fini)) 91 | 92 | . = ALIGN(4); 93 | _etext = .; /* define a global symbols at end of code */ 94 | } >FLASH 95 | 96 | /* Constant data goes into FLASH */ 97 | .rodata : 98 | { 99 | . = ALIGN(4); 100 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 101 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 102 | . = ALIGN(4); 103 | } >FLASH 104 | 105 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 106 | .ARM : { 107 | __exidx_start = .; 108 | *(.ARM.exidx*) 109 | __exidx_end = .; 110 | } >FLASH 111 | 112 | .preinit_array : 113 | { 114 | PROVIDE_HIDDEN (__preinit_array_start = .); 115 | KEEP (*(.preinit_array*)) 116 | PROVIDE_HIDDEN (__preinit_array_end = .); 117 | } >FLASH 118 | .init_array : 119 | { 120 | PROVIDE_HIDDEN (__init_array_start = .); 121 | KEEP (*(SORT(.init_array.*))) 122 | KEEP (*(.init_array*)) 123 | PROVIDE_HIDDEN (__init_array_end = .); 124 | } >FLASH 125 | .fini_array : 126 | { 127 | PROVIDE_HIDDEN (__fini_array_start = .); 128 | KEEP (*(SORT(.fini_array.*))) 129 | KEEP (*(.fini_array*)) 130 | PROVIDE_HIDDEN (__fini_array_end = .); 131 | } >FLASH 132 | 133 | /* used by the startup to initialize data */ 134 | _sidata = LOADADDR(.data); 135 | 136 | /* Initialized data sections goes into RAM, load LMA copy after code */ 137 | .data : 138 | { 139 | . = ALIGN(4); 140 | _sdata = .; /* create a global symbol at data start */ 141 | *(.data) /* .data sections */ 142 | *(.data*) /* .data* sections */ 143 | 144 | . = ALIGN(4); 145 | _edata = .; /* define a global symbol at data end */ 146 | } >RAM AT> FLASH 147 | 148 | 149 | /* Uninitialized data section */ 150 | . = ALIGN(4); 151 | .bss : 152 | { 153 | /* This is used by the startup in order to initialize the .bss secion */ 154 | _sbss = .; /* define a global symbol at bss start */ 155 | __bss_start__ = _sbss; 156 | *(.bss) 157 | *(.bss*) 158 | *(COMMON) 159 | 160 | . = ALIGN(4); 161 | _ebss = .; /* define a global symbol at bss end */ 162 | __bss_end__ = _ebss; 163 | } >RAM 164 | 165 | /* User_heap_stack section, used to check that there is enough RAM left */ 166 | ._user_heap_stack : 167 | { 168 | . = ALIGN(8); 169 | PROVIDE ( end = . ); 170 | PROVIDE ( _end = . ); 171 | . = . + _Min_Heap_Size; 172 | . = . + _Min_Stack_Size; 173 | . = ALIGN(8); 174 | } >RAM 175 | 176 | 177 | 178 | /* Remove information from the standard libraries */ 179 | /DISCARD/ : 180 | { 181 | libc.a ( * ) 182 | libm.a ( * ) 183 | libgcc.a ( * ) 184 | } 185 | 186 | .ARM.attributes 0 : { *(.ARM.attributes) } 187 | } 188 | 189 | 190 | -------------------------------------------------------------------------------- /CI/perf_counter_template_gcc/perf_counter_template_gcc.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | File.Version=6 3 | GPIO.groupedBy= 4 | KeepUserPlacement=false 5 | Mcu.Family=STM32F1 6 | Mcu.IP0=NVIC 7 | Mcu.IP1=RCC 8 | Mcu.IP2=SYS 9 | Mcu.IPNb=3 10 | Mcu.Name=STM32F103R(C-D-E)Tx 11 | Mcu.Package=LQFP64 12 | Mcu.Pin0=VP_SYS_VS_ND 13 | Mcu.Pin1=VP_SYS_VS_Systick 14 | Mcu.PinsNb=2 15 | Mcu.ThirdPartyNb=0 16 | Mcu.UserConstants= 17 | Mcu.UserName=STM32F103RCTx 18 | MxCube.Version=6.3.0 19 | MxDb.Version=DB.6.0.30 20 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 21 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false 22 | NVIC.ForceEnableDMAVector=true 23 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 24 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false 25 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false 26 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false 27 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 28 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false 29 | NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true 30 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 31 | PinOutPanel.RotationAngle=0 32 | ProjectManager.AskForMigrate=true 33 | ProjectManager.BackupPrevious=false 34 | ProjectManager.CompilerOptimize=6 35 | ProjectManager.ComputerToolchain=false 36 | ProjectManager.CoupleFile=false 37 | ProjectManager.CustomerFirmwarePackage= 38 | ProjectManager.DefaultFWLocation=true 39 | ProjectManager.DeletePrevious=true 40 | ProjectManager.DeviceId=STM32F103RCTx 41 | ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.8.4 42 | ProjectManager.FreePins=false 43 | ProjectManager.HalAssertFull=false 44 | ProjectManager.HeapSize=0x200 45 | ProjectManager.KeepUserCode=true 46 | ProjectManager.LastFirmware=true 47 | ProjectManager.LibraryCopy=1 48 | ProjectManager.MainLocation=Core/Src 49 | ProjectManager.NoMain=false 50 | ProjectManager.PreviousToolchain= 51 | ProjectManager.ProjectBuild=false 52 | ProjectManager.ProjectFileName=perf_counter_template_gcc.ioc 53 | ProjectManager.ProjectName=perf_counter_template_gcc 54 | ProjectManager.RegisterCallBack= 55 | ProjectManager.StackSize=0x400 56 | ProjectManager.TargetToolchain=Makefile 57 | ProjectManager.ToolChainLocation= 58 | ProjectManager.UnderRoot=false 59 | ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false 60 | RCC.APB1Freq_Value=8000000 61 | RCC.APB2Freq_Value=8000000 62 | RCC.FamilyName=M 63 | RCC.IPParameters=APB1Freq_Value,APB2Freq_Value,FamilyName,PLLCLKFreq_Value,PLLMCOFreq_Value,TimSysFreq_Value 64 | RCC.PLLCLKFreq_Value=8000000 65 | RCC.PLLMCOFreq_Value=4000000 66 | RCC.TimSysFreq_Value=8000000 67 | VP_SYS_VS_ND.Mode=No_Debug 68 | VP_SYS_VS_ND.Signal=SYS_VS_ND 69 | VP_SYS_VS_Systick.Mode=SysTick 70 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 71 | board=custom 72 | -------------------------------------------------------------------------------- /CI/perf_counter_template_gcc/platform.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright 2021 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) * 3 | * * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); * 5 | * you may not use this file except in compliance with the License. * 6 | * You may obtain a copy of the License at * 7 | * * 8 | * http://www.apache.org/licenses/LICENSE-2.0 * 9 | * * 10 | * Unless required by applicable law or agreed to in writing, software * 11 | * distributed under the License is distributed on an "AS IS" BASIS, * 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 13 | * See the License for the specific language governing permissions and * 14 | * limitations under the License. * 15 | * * 16 | ****************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "perf_counter.h" 22 | //#include "ARMCM0.h" // Keil::Board Support:V2M-MPS2:Common 23 | #include "main.h" 24 | #include 25 | 26 | extern 27 | void uart_config(uint32_t wUARTFrequency); 28 | 29 | 30 | __attribute__((weak)) 31 | void systimer_1ms_handler(void) 32 | { 33 | HAL_IncTick(); 34 | } 35 | 36 | static volatile uint32_t s_wMSCounter = 0; 37 | 38 | /*---------------------------------------------------------------------------- 39 | SysTick / Timer0 IRQ Handler 40 | *----------------------------------------------------------------------------*/ 41 | 42 | void SysTick_Handler (void) 43 | { 44 | if (s_wMSCounter) { 45 | s_wMSCounter--; 46 | } 47 | user_code_insert_to_systick_handler(); 48 | systimer_1ms_handler(); 49 | } 50 | 51 | /*! \brief initialise platform before main() 52 | */ 53 | __attribute__((constructor(101))) 54 | void platform_init(void) 55 | { 56 | SystemCoreClockUpdate(); 57 | 58 | uart_config(25000000ul); 59 | 60 | /* Generate interrupt each 1 ms */ 61 | SysTick_Config(SystemCoreClock / 1000); 62 | } 63 | 64 | 65 | -------------------------------------------------------------------------------- /SConscript: -------------------------------------------------------------------------------- 1 | Import('rtconfig') 2 | from building import * 3 | import os 4 | import shutil 5 | 6 | src = ['perf_counter.c', 'os/perf_os_patch_rt_thread.c'] 7 | cwd = GetCurrentDir() 8 | path = [cwd] 9 | CPPDEFINES = ['__PERF_COUNT_PLATFORM_SPECIFIC_HEADER__=', '__perf_counter_printf__=rt_kprintf'] 10 | 11 | if GetDepend('PKG_PERF_COUNTER_USING_THREAD_STATISTIC'): 12 | CPPDEFINES += ['__PERF_CNT_USE_RTOS__'] 13 | 14 | #delate unused files 15 | try: 16 | shutil.rmtree(os.path.join(cwd,'.github')) 17 | shutil.rmtree(os.path.join(cwd,'.vscode')) 18 | shutil.rmtree(os.path.join(cwd,'CI')) 19 | shutil.rmtree(os.path.join(cwd,'cmsis-pack')) 20 | shutil.rmtree(os.path.join(cwd,'lib')) 21 | shutil.rmtree(os.path.join(cwd,'example')) 22 | os.remove(os.path.join(cwd,'systick_wrapper_gcc.s')) 23 | os.remove(os.path.join(cwd,'systick_wrapper_gnu.s')) 24 | os.remove(os.path.join(cwd,'systick_wrapper_ual.s')) 25 | except: 26 | pass 27 | 28 | CXXFLAGS = '' 29 | 30 | if rtconfig.PLATFORM == 'armcc': # Keil AC5 31 | CXXFLAGS += ' --gnu' 32 | 33 | group = DefineGroup('perf_counter', src, depend = ['PKG_USING_PERF_COUNTER'], CPPDEFINES = CPPDEFINES, CPPPATH = path, CXXFLAGS = CXXFLAGS) 34 | 35 | Return('group') 36 | -------------------------------------------------------------------------------- /benchmark/coremark_port/core_portme.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Embedded Microprocessor Benchmark Consortium (EEMBC) 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | Original Author: Shay Gal-on 17 | */ 18 | 19 | #include 20 | #include 21 | #include "coremark.h" 22 | #include "perf_counter.h" 23 | 24 | #if VALIDATION_RUN 25 | volatile ee_s32 seed1_volatile = 0x3415; 26 | volatile ee_s32 seed2_volatile = 0x3415; 27 | volatile ee_s32 seed3_volatile = 0x66; 28 | #endif 29 | #if PERFORMANCE_RUN 30 | volatile ee_s32 seed1_volatile = 0x0; 31 | volatile ee_s32 seed2_volatile = 0x0; 32 | volatile ee_s32 seed3_volatile = 0x66; 33 | #endif 34 | #if PROFILE_RUN 35 | volatile ee_s32 seed1_volatile = 0x8; 36 | volatile ee_s32 seed2_volatile = 0x8; 37 | volatile ee_s32 seed3_volatile = 0x8; 38 | #endif 39 | volatile ee_s32 seed4_volatile = ITERATIONS; 40 | volatile ee_s32 seed5_volatile = 0; 41 | /* Porting : Timing functions 42 | How to capture time and convert to seconds must be ported to whatever is 43 | supported by the platform. e.g. Read value from on board RTC, read value from 44 | cpu clock cycles performance counter etc. Sample implementation for standard 45 | time.h and windows.h definitions included. 46 | */ 47 | /* Define : TIMER_RES_DIVIDER 48 | Divider to trade off timer resolution and total time that can be 49 | measured. 50 | 51 | Use lower values to increase resolution, but make sure that overflow 52 | does not occur. If there are issues with the return value overflowing, 53 | increase this value. 54 | */ 55 | #define NSECS_PER_SEC SystemCoreClock 56 | #define CORETIMETYPE clock_t 57 | #define GETMYTIME(_t) (*_t = clock()) 58 | #define MYTIMEDIFF(fin, ini) ((fin) - (ini)) 59 | #define TIMER_RES_DIVIDER 1 60 | #define SAMPLE_TIME_IMPLEMENTATION 1 61 | #define EE_TICKS_PER_SEC (NSECS_PER_SEC / TIMER_RES_DIVIDER) 62 | 63 | /** Define Host specific (POSIX), or target specific global time variables. */ 64 | //static CORETIMETYPE start_time_val, stop_time_val; 65 | 66 | extern uint32_t SystemCoreClock; 67 | 68 | static volatile CORE_TICKS s_tCycleElapsed = 0; 69 | 70 | /* Function : start_time 71 | This function will be called right before starting the timed portion of 72 | the benchmark. 73 | 74 | Implementation may be capturing a system timer (as implemented in the 75 | example code) or zeroing some system parameters - e.g. setting the cpu clocks 76 | cycles to 0. 77 | */ 78 | void 79 | start_time(void) 80 | { 81 | start_cycle_counter(); 82 | } 83 | /* Function : stop_time 84 | This function will be called right after ending the timed portion of the 85 | benchmark. 86 | 87 | Implementation may be capturing a system timer (as implemented in the 88 | example code) or other system parameters - e.g. reading the current value of 89 | cpu cycles counter. 90 | */ 91 | void 92 | stop_time(void) 93 | { 94 | s_tCycleElapsed = stop_cycle_counter(); 95 | } 96 | /* Function : get_time 97 | Return an abstract "ticks" number that signifies time on the system. 98 | 99 | Actual value returned may be cpu cycles, milliseconds or any other 100 | value, as long as it can be converted to seconds by . This 101 | methodology is taken to accommodate any hardware or simulated platform. The 102 | sample implementation returns millisecs by default, and the resolution is 103 | controlled by 104 | */ 105 | CORE_TICKS 106 | get_time(void) 107 | { 108 | return s_tCycleElapsed; 109 | } 110 | /* Function : time_in_secs 111 | Convert the value returned by get_time to seconds. 112 | 113 | The type is used to accommodate systems with no support for 114 | floating point. Default implementation implemented by the EE_TICKS_PER_SEC 115 | macro above. 116 | */ 117 | secs_ret 118 | time_in_secs(CORE_TICKS ticks) 119 | { 120 | secs_ret retval = ((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC; 121 | return retval; 122 | } 123 | 124 | ee_u32 default_num_contexts = 1; 125 | 126 | /* Function : portable_init 127 | Target specific initialization code 128 | Test for some common mistakes. 129 | */ 130 | void 131 | portable_init(core_portable *p, int *argc, char *argv[]) 132 | { 133 | init_cycle_counter(false); 134 | 135 | (void)argc; // prevent unused warning 136 | (void)argv; // prevent unused warning 137 | 138 | if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) 139 | { 140 | ee_printf( 141 | "ERROR! Please define ee_ptr_int to a type that holds a " 142 | "pointer!\n"); 143 | } 144 | if (sizeof(ee_u32) != 4) 145 | { 146 | ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n"); 147 | } 148 | p->portable_id = 1; 149 | } 150 | /* Function : portable_fini 151 | Target specific final code 152 | */ 153 | void 154 | portable_fini(core_portable *p) 155 | { 156 | p->portable_id = 0; 157 | } 158 | -------------------------------------------------------------------------------- /benchmark/coremark_port/core_portme.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 Embedded Microprocessor Benchmark Consortium (EEMBC) 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | Original Author: Shay Gal-on 17 | */ 18 | 19 | /* Topic : Description 20 | This file contains configuration constants required to execute on 21 | different platforms 22 | */ 23 | #ifndef CORE_PORTME_H 24 | #define CORE_PORTME_H 25 | 26 | #include "perf_counter.h" 27 | 28 | #if defined(__clang__) 29 | # pragma clang diagnostic ignored "-Wunknown-warning-option" 30 | # pragma clang diagnostic ignored "-Wreserved-identifier" 31 | # pragma clang diagnostic ignored "-Wundef" 32 | # pragma clang diagnostic ignored "-Wmissing-variable-declarations" 33 | # pragma clang diagnostic ignored "-Wpadded" 34 | # pragma clang diagnostic ignored "-Wstrict-prototypes" 35 | # pragma clang diagnostic ignored "-Wswitch-enum" 36 | #endif 37 | 38 | 39 | /************************/ 40 | /* Data types and settings */ 41 | /************************/ 42 | /* Configuration : HAS_FLOAT 43 | Define to 1 if the platform supports floating point. 44 | */ 45 | #ifndef HAS_FLOAT 46 | #define HAS_FLOAT 1 47 | #endif 48 | /* Configuration : HAS_TIME_H 49 | Define to 1 if platform has the time.h header file, 50 | and implementation of functions thereof. 51 | */ 52 | #ifndef HAS_TIME_H 53 | #define HAS_TIME_H 1 54 | #endif 55 | /* Configuration : USE_CLOCK 56 | Define to 1 if platform has the time.h header file, 57 | and implementation of functions thereof. 58 | */ 59 | #ifndef USE_CLOCK 60 | #define USE_CLOCK 1 61 | #endif 62 | /* Configuration : HAS_STDIO 63 | Define to 1 if the platform has stdio.h. 64 | */ 65 | #ifndef HAS_STDIO 66 | #define HAS_STDIO 1 67 | #endif 68 | /* Configuration : HAS_PRINTF 69 | Define to 1 if the platform has stdio.h and implements the printf 70 | function. 71 | */ 72 | #ifndef HAS_PRINTF 73 | #define HAS_PRINTF 1 74 | #endif 75 | 76 | /* Configuration : CORE_TICKS 77 | Define type of return from the timing functions. 78 | */ 79 | typedef int64_t CORE_TICKS; 80 | 81 | /* Definitions : COMPILER_VERSION, COMPILER_FLAGS, MEM_LOCATION 82 | Initialize these strings per platform 83 | */ 84 | #ifndef COMPILER_VERSION 85 | 86 | #if __IS_COMPILER_ARM_COMPILER_6__ 87 | #define COMPILER_VERSION "Arm Compiler 6" 88 | #elif __IS_COMPILER_ARM_COMPILER_5__ 89 | #define COMPILER_VERSION "Arm Compiler 5" 90 | #elif __IS_COMPILER_LLVM__ 91 | #define COMPILER_VERSION __VERSION__ 92 | #elif __IS_COMPILER_IAR__ 93 | #define COMPILER_VERSION "IAR" 94 | #elif __IS_COMPILER_GCC__ 95 | #define COMPILER_VERSION "GCC"__VERSION__ 96 | #else 97 | #define COMPILER_VERSION "Please put compiler version here (e.g. gcc 4.1)" 98 | #endif 99 | 100 | 101 | #endif 102 | #ifndef COMPILER_FLAGS 103 | #define COMPILER_FLAGS \ 104 | "Unspecified" /* "Please put compiler flags here (e.g. -o3)" */ 105 | #endif 106 | 107 | 108 | /* Data Types : 109 | To avoid compiler issues, define the data types that need ot be used for 110 | 8b, 16b and 32b in . 111 | 112 | *Imprtant* : 113 | ee_ptr_int needs to be the data type used to hold pointers, otherwise 114 | coremark may fail!!! 115 | */ 116 | typedef signed short ee_s16; 117 | typedef unsigned short ee_u16; 118 | typedef signed int ee_s32; 119 | typedef double ee_f32; 120 | typedef unsigned char ee_u8; 121 | typedef unsigned int ee_u32; 122 | typedef ee_u32 ee_ptr_int; 123 | typedef size_t ee_size_t; 124 | /* align_mem : 125 | This macro is used to align an offset to point to a 32b value. It is 126 | used in the Matrix algorithm to initialize the input memory blocks. 127 | */ 128 | #define align_mem(x) (void *)(4 + (((ee_ptr_int)(x)-1) & ~3)) 129 | 130 | /* Configuration : SEED_METHOD 131 | Defines method to get seed values that cannot be computed at compile 132 | time. 133 | 134 | Valid values : 135 | SEED_ARG - from command line. 136 | SEED_FUNC - from a system function. 137 | SEED_VOLATILE - from volatile variables. 138 | */ 139 | #ifndef SEED_METHOD 140 | #define SEED_METHOD SEED_VOLATILE 141 | #endif 142 | 143 | /* Configuration : MEM_METHOD 144 | Defines method to get a block of memry. 145 | 146 | Valid values : 147 | MEM_MALLOC - for platforms that implement malloc and have malloc.h. 148 | MEM_STATIC - to use a static memory array. 149 | MEM_STACK - to allocate the data block on the stack (NYI). 150 | */ 151 | #ifndef MEM_METHOD 152 | #define MEM_METHOD MEM_STACK 153 | #endif 154 | 155 | #undef MEM_LOCATION 156 | #if MEM_METHOD == MEM_MALLOC 157 | # define MEM_LOCATION "MALLOC" 158 | #elif MEM_METHOD == MEM_STATIC 159 | # define MEM_LOCATION "STATIC" 160 | #elif MEM_METHOD == MEM_STACK 161 | # define MEM_LOCATION "STACK" 162 | #endif 163 | 164 | 165 | /* Configuration : MULTITHREAD 166 | Define for parallel execution 167 | 168 | Valid values : 169 | 1 - only one context (default). 170 | N>1 - will execute N copies in parallel. 171 | 172 | Note : 173 | If this flag is defined to more then 1, an implementation for launching 174 | parallel contexts must be defined. 175 | 176 | Two sample implementations are provided. Use or 177 | to enable them. 178 | 179 | It is valid to have a different implementation of 180 | and in , to fit a particular architecture. 181 | */ 182 | #ifndef MULTITHREAD 183 | #define MULTITHREAD 1 184 | #define USE_PTHREAD 0 185 | #define USE_FORK 0 186 | #define USE_SOCKET 0 187 | #endif 188 | 189 | /* Configuration : MAIN_HAS_NOARGC 190 | Needed if platform does not support getting arguments to main. 191 | 192 | Valid values : 193 | 0 - argc/argv to main is supported 194 | 1 - argc/argv to main is not supported 195 | 196 | Note : 197 | This flag only matters if MULTITHREAD has been defined to a value 198 | greater then 1. 199 | */ 200 | #ifndef MAIN_HAS_NOARGC 201 | #define MAIN_HAS_NOARGC 0 202 | #endif 203 | 204 | /* Configuration : MAIN_HAS_NORETURN 205 | Needed if platform does not support returning a value from main. 206 | 207 | Valid values : 208 | 0 - main returns an int, and return value will be 0. 209 | 1 - platform does not support returning a value from main 210 | */ 211 | #ifndef MAIN_HAS_NORETURN 212 | #define MAIN_HAS_NORETURN 0 213 | #endif 214 | 215 | #ifndef ITERATIONS 216 | #define ITERATIONS 3000 217 | #endif 218 | 219 | /* Variable : default_num_contexts 220 | Not used for this simple port, must contain the value 1. 221 | */ 222 | extern ee_u32 default_num_contexts; 223 | 224 | typedef struct CORE_PORTABLE_S 225 | { 226 | ee_u8 portable_id; 227 | } core_portable; 228 | 229 | void coremark_main(void); 230 | 231 | /* target specific init/fini */ 232 | void portable_init(core_portable *p, int *argc, char *argv[]); 233 | void portable_fini(core_portable *p); 234 | 235 | #if !defined(PROFILE_RUN) && !defined(PERFORMANCE_RUN) \ 236 | && !defined(VALIDATION_RUN) 237 | #if (TOTAL_DATA_SIZE == 1200) 238 | #define PROFILE_RUN 1 239 | #elif (TOTAL_DATA_SIZE == 2000) 240 | #define PERFORMANCE_RUN 1 241 | #else 242 | #define VALIDATION_RUN 1 243 | #endif 244 | #endif 245 | 246 | #endif /* CORE_PORTME_H */ 247 | -------------------------------------------------------------------------------- /benchmark/coremark_port/core_portme.mak: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Embedded Microprocessor Benchmark Consortium (EEMBC) 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | # Original Author: Shay Gal-on 16 | 17 | #File : core_portme.mak 18 | 19 | # Flag : OUTFLAG 20 | # Use this flag to define how to to get an executable (e.g -o) 21 | OUTFLAG= -o 22 | # Flag : CC 23 | # Use this flag to define compiler to use 24 | CC = gcc 25 | # Flag : CFLAGS 26 | # Use this flag to define compiler options. Note, you can add compiler options from the command line using XCFLAGS="other flags" 27 | PORT_CFLAGS = -O2 28 | FLAGS_STR = "$(PORT_CFLAGS) $(XCFLAGS) $(XLFLAGS) $(LFLAGS_END)" 29 | CFLAGS = $(PORT_CFLAGS) -I$(PORT_DIR) -I. -DFLAGS_STR=\"$(FLAGS_STR)\" 30 | #Flag : LFLAGS_END 31 | # Define any libraries needed for linking or other flags that should come at the end of the link line (e.g. linker scripts). 32 | # Note : On certain platforms, the default clock_gettime implementation is supported but requires linking of librt. 33 | LFLAGS_END = 34 | # Flag : PORT_SRCS 35 | # Port specific source files can be added here 36 | PORT_SRCS = $(PORT_DIR)/core_portme.c 37 | # Flag : LOAD 38 | # For a simple port, we assume self hosted compile and run, no load needed. 39 | 40 | # Flag : RUN 41 | # For a simple port, we assume self hosted compile and run, simple invocation of the executable 42 | 43 | #For native compilation and execution 44 | LOAD = echo Loading done 45 | RUN = 46 | 47 | OEXT = .o 48 | EXE = .exe 49 | 50 | # Target : port_pre% and port_post% 51 | # For the purpose of this simple port, no pre or post steps needed. 52 | 53 | .PHONY : port_prebuild port_postbuild port_prerun port_postrun port_preload port_postload 54 | port_pre% port_post% : 55 | 56 | # FLAG : OPATH 57 | # Path to the output folder. Default - current folder. 58 | OPATH = ./ 59 | MKDIR = mkdir -p 60 | 61 | -------------------------------------------------------------------------------- /cmsis-pack/GorgonMeducer.perf_counter.2.4.0.pack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GorgonMeducer/perf_counter/3dfee7d3f4b201b7b857fb1445800b251d9f27e5/cmsis-pack/GorgonMeducer.perf_counter.2.4.0.pack -------------------------------------------------------------------------------- /cmsis-pack/GorgonMeducer.pidx: -------------------------------------------------------------------------------- 1 | 2 | 3 | GorgonMeducer 4 | https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/ 5 | 2024-12-08 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /documents/pictures/GNU_in_AC5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GorgonMeducer/perf_counter/3dfee7d3f4b201b7b857fb1445800b251d9f27e5/documents/pictures/GNU_in_AC5 -------------------------------------------------------------------------------- /documents/pictures/RTE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GorgonMeducer/perf_counter/3dfee7d3f4b201b7b857fb1445800b251d9f27e5/documents/pictures/RTE -------------------------------------------------------------------------------- /documents/pictures/RTE_cmsis_core: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GorgonMeducer/perf_counter/3dfee7d3f4b201b7b857fb1445800b251d9f27e5/documents/pictures/RTE_cmsis_core -------------------------------------------------------------------------------- /documents/pictures/__cpu_perf__output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GorgonMeducer/perf_counter/3dfee7d3f4b201b7b857fb1445800b251d9f27e5/documents/pictures/__cpu_perf__output.png -------------------------------------------------------------------------------- /documents/pictures/__cycleof___output_non_printf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GorgonMeducer/perf_counter/3dfee7d3f4b201b7b857fb1445800b251d9f27e5/documents/pictures/__cycleof___output_non_printf -------------------------------------------------------------------------------- /documents/pictures/__cycleof___output_simple: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GorgonMeducer/perf_counter/3dfee7d3f4b201b7b857fb1445800b251d9f27e5/documents/pictures/__cycleof___output_simple -------------------------------------------------------------------------------- /documents/pictures/check_for_updates: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GorgonMeducer/perf_counter/3dfee7d3f4b201b7b857fb1445800b251d9f27e5/documents/pictures/check_for_updates -------------------------------------------------------------------------------- /documents/pictures/gnu_in_ac6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GorgonMeducer/perf_counter/3dfee7d3f4b201b7b857fb1445800b251d9f27e5/documents/pictures/gnu_in_ac6 -------------------------------------------------------------------------------- /documents/pictures/pack_installer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GorgonMeducer/perf_counter/3dfee7d3f4b201b7b857fb1445800b251d9f27e5/documents/pictures/pack_installer -------------------------------------------------------------------------------- /documents/pictures/rt-thread-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GorgonMeducer/perf_counter/3dfee7d3f4b201b7b857fb1445800b251d9f27e5/documents/pictures/rt-thread-settings.png -------------------------------------------------------------------------------- /example/RTE/Compiler/EventRecorderConf.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------ 2 | * MDK - Component ::Event Recorder 3 | * Copyright (c) 2016-2018 ARM Germany GmbH. All rights reserved. 4 | *------------------------------------------------------------------------------ 5 | * Name: EventRecorderConf.h 6 | * Purpose: Event Recorder Configuration 7 | * Rev.: V1.1.0 8 | *----------------------------------------------------------------------------*/ 9 | 10 | //-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- 11 | 12 | // Event Recorder 13 | 14 | // Number of Records 15 | // <8=>8 <16=>16 <32=>32 <64=>64 <128=>128 <256=>256 <512=>512 <1024=>1024 16 | // <2048=>2048 <4096=>4096 <8192=>8192 <16384=>16384 <32768=>32768 17 | // <65536=>65536 18 | // Configures size of Event Record Buffer (each record is 16 bytes) 19 | // Must be 2^n (min=8, max=65536) 20 | #define EVENT_RECORD_COUNT 64U 21 | 22 | // Time Stamp Source 23 | // <0=> DWT Cycle Counter <1=> SysTick <2=> CMSIS-RTOS2 System Timer 24 | // <3=> User Timer (Normal Reset) <4=> User Timer (Power-On Reset) 25 | // Selects source for 32-bit time stamp 26 | #define EVENT_TIMESTAMP_SOURCE 3 27 | 28 | // Time Stamp Clock Frequency [Hz] <0-1000000000> 29 | // Defines initial time stamp clock frequency (0 when not used) 30 | #define EVENT_TIMESTAMP_FREQ 0U 31 | 32 | // 33 | 34 | //------------- <<< end of configuration section >>> --------------------------- 35 | -------------------------------------------------------------------------------- /example/RTE/Device/ARMCM0/ARMCM0_ac6.sct: -------------------------------------------------------------------------------- 1 | #! armclang -E --target=arm-arm-none-eabi -mcpu=cortex-m0 -xc 2 | ; command above MUST be in first line (no comment above!) 3 | 4 | /* 5 | ;-------- <<< Use Configuration Wizard in Context Menu >>> ------------------- 6 | */ 7 | 8 | /*--------------------- Flash Configuration ---------------------------------- 9 | ; Flash Configuration 10 | ; Flash Base Address <0x0-0xFFFFFFFF:8> 11 | ; Flash Size (in Bytes) <0x0-0xFFFFFFFF:8> 12 | ; 13 | *----------------------------------------------------------------------------*/ 14 | #define __ROM_BASE 0x00000000 15 | #define __ROM_SIZE 0x00080000 16 | 17 | /*--------------------- Embedded RAM Configuration --------------------------- 18 | ; RAM Configuration 19 | ; RAM Base Address <0x0-0xFFFFFFFF:8> 20 | ; RAM Size (in Bytes) <0x0-0xFFFFFFFF:8> 21 | ; 22 | *----------------------------------------------------------------------------*/ 23 | #define __RAM_BASE 0x20000000 24 | #define __RAM_SIZE 0x00040000 25 | 26 | /*--------------------- Stack / Heap Configuration --------------------------- 27 | ; Stack / Heap Configuration 28 | ; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> 29 | ; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> 30 | ; 31 | *----------------------------------------------------------------------------*/ 32 | #define __STACK_SIZE 0x00000200 33 | #define __HEAP_SIZE 0x00000C00 34 | 35 | /* 36 | ;------------- <<< end of configuration section >>> --------------------------- 37 | */ 38 | 39 | 40 | /*---------------------------------------------------------------------------- 41 | User Stack & Heap boundary definition 42 | *----------------------------------------------------------------------------*/ 43 | #define __STACK_TOP (__RAM_BASE + __RAM_SIZE) /* starts at end of RAM */ 44 | #define __HEAP_BASE (AlignExpr(+0, 8)) /* starts after RW_RAM section, 8 byte aligned */ 45 | 46 | 47 | /*---------------------------------------------------------------------------- 48 | Scatter File Definitions definition 49 | *----------------------------------------------------------------------------*/ 50 | #define __RO_BASE __ROM_BASE 51 | #define __RO_SIZE __ROM_SIZE 52 | 53 | #define __RW_BASE __RAM_BASE 54 | #define __RW_SIZE (__RAM_SIZE - __STACK_SIZE - __HEAP_SIZE) 55 | 56 | 57 | LR_ROM __RO_BASE __RO_SIZE { ; load region size_region 58 | ER_ROM __RO_BASE __RO_SIZE { ; load address = execution address 59 | *.o (RESET, +First) 60 | *(InRoot$$Sections) 61 | .ANY (+RO) 62 | .ANY (+XO) 63 | } 64 | 65 | RW_NOINIT __RW_BASE UNINIT __RW_SIZE { 66 | *(.bss.noinit) 67 | } 68 | 69 | RW_RAM AlignExpr(+0, 8) (__RW_SIZE - AlignExpr(ImageLength(RW_NOINIT), 8)) { 70 | *(+RW +ZI) 71 | } 72 | 73 | #if __HEAP_SIZE > 0 74 | ARM_LIB_HEAP __HEAP_BASE EMPTY __HEAP_SIZE { ; Reserve empty region for heap 75 | } 76 | #endif 77 | 78 | ARM_LIB_STACK __STACK_TOP EMPTY -__STACK_SIZE { ; Reserve empty region for stack 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /example/RTE/Device/ARMCM0/gcc_arm.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GorgonMeducer/perf_counter/3dfee7d3f4b201b7b857fb1445800b251d9f27e5/example/RTE/Device/ARMCM0/gcc_arm.ld -------------------------------------------------------------------------------- /example/RTE/Device/ARMCM0/startup_ARMCM0.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file startup_ARMCM0.c 3 | * @brief CMSIS-Core(M) Device Startup File for a Cortex-M0 Device 4 | * @version V2.0.3 5 | * @date 31. March 2020 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2020 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined (ARMCM0) 26 | #include "ARMCM0.h" 27 | #else 28 | #error device not specified! 29 | #endif 30 | 31 | /*---------------------------------------------------------------------------- 32 | External References 33 | *----------------------------------------------------------------------------*/ 34 | extern uint32_t __INITIAL_SP; 35 | 36 | extern __NO_RETURN void __PROGRAM_START(void); 37 | 38 | /*---------------------------------------------------------------------------- 39 | Internal References 40 | *----------------------------------------------------------------------------*/ 41 | __NO_RETURN void Reset_Handler (void); 42 | void Default_Handler(void); 43 | 44 | /*---------------------------------------------------------------------------- 45 | Exception / Interrupt Handler 46 | *----------------------------------------------------------------------------*/ 47 | /* Exceptions */ 48 | void NMI_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 49 | void HardFault_Handler (void) __attribute__ ((weak)); 50 | void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 51 | void PendSV_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 52 | void SysTick_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 53 | 54 | void Interrupt0_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 55 | void Interrupt1_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 56 | void Interrupt2_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 57 | void Interrupt3_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 58 | void Interrupt4_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 59 | void Interrupt5_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 60 | void Interrupt6_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 61 | void Interrupt7_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 62 | void Interrupt8_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 63 | void Interrupt9_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 64 | 65 | 66 | /*---------------------------------------------------------------------------- 67 | Exception / Interrupt Vector table 68 | *----------------------------------------------------------------------------*/ 69 | 70 | #if defined ( __GNUC__ ) 71 | #pragma GCC diagnostic push 72 | #pragma GCC diagnostic ignored "-Wpedantic" 73 | #endif 74 | 75 | extern const VECTOR_TABLE_Type __VECTOR_TABLE[48]; 76 | const VECTOR_TABLE_Type __VECTOR_TABLE[48] __VECTOR_TABLE_ATTRIBUTE = { 77 | (VECTOR_TABLE_Type)(&__INITIAL_SP), /* Initial Stack Pointer */ 78 | Reset_Handler, /* Reset Handler */ 79 | NMI_Handler, /* -14 NMI Handler */ 80 | HardFault_Handler, /* -13 Hard Fault Handler */ 81 | 0, /* Reserved */ 82 | 0, /* Reserved */ 83 | 0, /* Reserved */ 84 | 0, /* Reserved */ 85 | 0, /* Reserved */ 86 | 0, /* Reserved */ 87 | 0, /* Reserved */ 88 | SVC_Handler, /* -5 SVCall Handler */ 89 | 0, /* Reserved */ 90 | 0, /* Reserved */ 91 | PendSV_Handler, /* -2 PendSV Handler */ 92 | SysTick_Handler, /* -1 SysTick Handler */ 93 | 94 | /* Interrupts */ 95 | Interrupt0_Handler, /* 0 Interrupt 0 */ 96 | Interrupt1_Handler, /* 1 Interrupt 1 */ 97 | Interrupt2_Handler, /* 2 Interrupt 2 */ 98 | Interrupt3_Handler, /* 3 Interrupt 3 */ 99 | Interrupt4_Handler, /* 4 Interrupt 4 */ 100 | Interrupt5_Handler, /* 5 Interrupt 5 */ 101 | Interrupt6_Handler, /* 6 Interrupt 6 */ 102 | Interrupt7_Handler, /* 7 Interrupt 7 */ 103 | Interrupt8_Handler, /* 8 Interrupt 8 */ 104 | Interrupt9_Handler /* 9 Interrupt 9 */ 105 | /* Interrupts 10..31 are left out */ 106 | }; 107 | 108 | #if defined ( __GNUC__ ) 109 | #pragma GCC diagnostic pop 110 | #endif 111 | 112 | /*---------------------------------------------------------------------------- 113 | Reset Handler called on controller reset 114 | *----------------------------------------------------------------------------*/ 115 | __NO_RETURN void Reset_Handler(void) 116 | { 117 | SystemInit(); /* CMSIS System Initialization */ 118 | __PROGRAM_START(); /* Enter PreMain (C library entry point) */ 119 | } 120 | 121 | 122 | #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 123 | #pragma clang diagnostic push 124 | #pragma clang diagnostic ignored "-Wmissing-noreturn" 125 | #endif 126 | 127 | /*---------------------------------------------------------------------------- 128 | Hard Fault Handler 129 | *----------------------------------------------------------------------------*/ 130 | void HardFault_Handler(void) 131 | { 132 | while(1); 133 | } 134 | 135 | /*---------------------------------------------------------------------------- 136 | Default Handler for Exceptions / Interrupts 137 | *----------------------------------------------------------------------------*/ 138 | void Default_Handler(void) 139 | { 140 | while(1); 141 | } 142 | 143 | #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 144 | #pragma clang diagnostic pop 145 | #endif 146 | 147 | -------------------------------------------------------------------------------- /example/RTE/Device/ARMCM0/startup_ARMCM0.s: -------------------------------------------------------------------------------- 1 | ;/**************************************************************************//** 2 | ; * @file startup_ARMCM0.s 3 | ; * @brief CMSIS Core Device Startup File for 4 | ; * ARMCM0 Device 5 | ; * @version V1.0.1 6 | ; * @date 23. July 2019 7 | ; ******************************************************************************/ 8 | ;/* 9 | ; * Copyright (c) 2009-2019 Arm Limited. All rights reserved. 10 | ; * 11 | ; * SPDX-License-Identifier: Apache-2.0 12 | ; * 13 | ; * Licensed under the Apache License, Version 2.0 (the License); you may 14 | ; * not use this file except in compliance with the License. 15 | ; * You may obtain a copy of the License at 16 | ; * 17 | ; * www.apache.org/licenses/LICENSE-2.0 18 | ; * 19 | ; * Unless required by applicable law or agreed to in writing, software 20 | ; * distributed under the License is distributed on an AS IS BASIS, WITHOUT 21 | ; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | ; * See the License for the specific language governing permissions and 23 | ; * limitations under the License. 24 | ; */ 25 | 26 | ;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ 27 | 28 | 29 | ; Stack Configuration 30 | ; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> 31 | ; 32 | 33 | ;Stack_Size EQU 0x00000400 34 | 35 | ; AREA STACK, NOINIT, READWRITE, ALIGN=3 36 | ;__stack_limit 37 | ;Stack_Mem SPACE Stack_Size 38 | ;__initial_sp 39 | 40 | 41 | ;; Heap Configuration 42 | ;; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> 43 | ;; 44 | 45 | ;Heap_Size EQU 0x00000C00 46 | 47 | ; IF Heap_Size != 0 ; Heap is provided 48 | ; AREA HEAP, NOINIT, READWRITE, ALIGN=3 49 | ;__heap_base 50 | ;Heap_Mem SPACE Heap_Size 51 | ;__heap_limit 52 | ; ENDIF 53 | 54 | 55 | PRESERVE8 56 | THUMB 57 | 58 | 59 | ; Vector Table Mapped to Address 0 at Reset 60 | 61 | AREA RESET, DATA, READONLY 62 | EXPORT __Vectors 63 | EXPORT __Vectors_End 64 | EXPORT __Vectors_Size 65 | IMPORT |Image$$ARM_LIB_STACK$$ZI$$Limit| 66 | 67 | __Vectors DCD |Image$$ARM_LIB_STACK$$ZI$$Limit| ; Top of Stack 68 | DCD Reset_Handler ; Reset Handler 69 | DCD NMI_Handler ; -14 NMI Handler 70 | DCD HardFault_Handler ; -13 Hard Fault Handler 71 | DCD 0 ; Reserved 72 | DCD 0 ; Reserved 73 | DCD 0 ; Reserved 74 | DCD 0 ; Reserved 75 | DCD 0 ; Reserved 76 | DCD 0 ; Reserved 77 | DCD 0 ; Reserved 78 | DCD SVC_Handler ; -5 SVCall Handler 79 | DCD 0 ; Reserved 80 | DCD 0 ; Reserved 81 | DCD PendSV_Handler ; -2 PendSV Handler 82 | DCD SysTick_Handler ; -1 SysTick Handler 83 | 84 | ; Interrupts 85 | DCD Interrupt0_Handler ; 0 Interrupt 0 86 | DCD Interrupt1_Handler ; 1 Interrupt 1 87 | DCD Interrupt2_Handler ; 2 Interrupt 2 88 | DCD Interrupt3_Handler ; 3 Interrupt 3 89 | DCD Interrupt4_Handler ; 4 Interrupt 4 90 | DCD Interrupt5_Handler ; 5 Interrupt 5 91 | DCD Interrupt6_Handler ; 6 Interrupt 6 92 | DCD Interrupt7_Handler ; 7 Interrupt 7 93 | DCD Interrupt8_Handler ; 8 Interrupt 8 94 | DCD Interrupt9_Handler ; 9 Interrupt 9 95 | 96 | SPACE ( 22 * 4) ; Interrupts 10 .. 31 are left out 97 | __Vectors_End 98 | __Vectors_Size EQU __Vectors_End - __Vectors 99 | 100 | 101 | AREA |.text|, CODE, READONLY 102 | 103 | ; Reset Handler 104 | 105 | Reset_Handler PROC 106 | EXPORT Reset_Handler [WEAK] 107 | IMPORT SystemInit 108 | IMPORT __main 109 | 110 | LDR R0, =SystemInit 111 | BLX R0 112 | LDR R0, =__main 113 | BX R0 114 | ENDP 115 | 116 | ; The default macro is not used for HardFault_Handler 117 | ; because this results in a poor debug illusion. 118 | HardFault_Handler PROC 119 | EXPORT HardFault_Handler [WEAK] 120 | B . 121 | ENDP 122 | 123 | ; Macro to define default exception/interrupt handlers. 124 | ; Default handler are weak symbols with an endless loop. 125 | ; They can be overwritten by real handlers. 126 | MACRO 127 | Set_Default_Handler $Handler_Name 128 | $Handler_Name PROC 129 | EXPORT $Handler_Name [WEAK] 130 | B . 131 | ENDP 132 | MEND 133 | 134 | 135 | ; Default exception/interrupt handler 136 | 137 | Set_Default_Handler NMI_Handler 138 | Set_Default_Handler SVC_Handler 139 | Set_Default_Handler PendSV_Handler 140 | Set_Default_Handler SysTick_Handler 141 | 142 | Set_Default_Handler Interrupt0_Handler 143 | Set_Default_Handler Interrupt1_Handler 144 | Set_Default_Handler Interrupt2_Handler 145 | Set_Default_Handler Interrupt3_Handler 146 | Set_Default_Handler Interrupt4_Handler 147 | Set_Default_Handler Interrupt5_Handler 148 | Set_Default_Handler Interrupt6_Handler 149 | Set_Default_Handler Interrupt7_Handler 150 | Set_Default_Handler Interrupt8_Handler 151 | Set_Default_Handler Interrupt9_Handler 152 | 153 | ALIGN 154 | 155 | 156 | ; User setup Stack & Heap 157 | 158 | ; IF :LNOT::DEF:__MICROLIB 159 | ; IMPORT __use_two_region_memory 160 | ; ENDIF 161 | 162 | ; EXPORT __stack_limit 163 | ; EXPORT __initial_sp 164 | ; IF Heap_Size != 0 ; Heap is provided 165 | ; EXPORT __heap_base 166 | ; EXPORT __heap_limit 167 | ; ENDIF 168 | 169 | END 170 | -------------------------------------------------------------------------------- /example/RTE/Device/ARMCM0/system_ARMCM0.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file system_ARMCM0.c 3 | * @brief CMSIS Device System Source File for 4 | * ARMCM0 Device 5 | * @version V1.0.0 6 | * @date 09. July 2018 7 | ******************************************************************************/ 8 | /* 9 | * Copyright (c) 2009-2018 Arm Limited. All rights reserved. 10 | * 11 | * SPDX-License-Identifier: Apache-2.0 12 | * 13 | * Licensed under the Apache License, Version 2.0 (the License); you may 14 | * not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at 16 | * 17 | * www.apache.org/licenses/LICENSE-2.0 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 21 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | */ 25 | 26 | #include "ARMCM0.h" 27 | 28 | /*---------------------------------------------------------------------------- 29 | Define clocks 30 | *----------------------------------------------------------------------------*/ 31 | #define XTAL (50000000UL) /* Oscillator frequency */ 32 | 33 | #define SYSTEM_CLOCK (XTAL / 2U) 34 | 35 | 36 | /*---------------------------------------------------------------------------- 37 | System Core Clock Variable 38 | *----------------------------------------------------------------------------*/ 39 | uint32_t SystemCoreClock = SYSTEM_CLOCK; /* System Core Clock Frequency */ 40 | 41 | 42 | /*---------------------------------------------------------------------------- 43 | System Core Clock update function 44 | *----------------------------------------------------------------------------*/ 45 | void SystemCoreClockUpdate (void) 46 | { 47 | SystemCoreClock = SYSTEM_CLOCK; 48 | } 49 | 50 | /*---------------------------------------------------------------------------- 51 | System initialization function 52 | *----------------------------------------------------------------------------*/ 53 | void SystemInit (void) 54 | { 55 | SystemCoreClock = SYSTEM_CLOCK; 56 | } 57 | -------------------------------------------------------------------------------- /example/RTE/Device/ARMCM3/startup_ARMCM3.s: -------------------------------------------------------------------------------- 1 | ;/**************************************************************************//** 2 | ; * @file startup_ARMCM3.s 3 | ; * @brief CMSIS Core Device Startup File for 4 | ; * ARMCM3 Device 5 | ; * @version V1.0.1 6 | ; * @date 23. July 2019 7 | ; ******************************************************************************/ 8 | ;/* 9 | ; * Copyright (c) 2009-2019 Arm Limited. All rights reserved. 10 | ; * 11 | ; * SPDX-License-Identifier: Apache-2.0 12 | ; * 13 | ; * Licensed under the Apache License, Version 2.0 (the License); you may 14 | ; * not use this file except in compliance with the License. 15 | ; * You may obtain a copy of the License at 16 | ; * 17 | ; * www.apache.org/licenses/LICENSE-2.0 18 | ; * 19 | ; * Unless required by applicable law or agreed to in writing, software 20 | ; * distributed under the License is distributed on an AS IS BASIS, WITHOUT 21 | ; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | ; * See the License for the specific language governing permissions and 23 | ; * limitations under the License. 24 | ; */ 25 | 26 | ;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ 27 | 28 | 29 | ; Stack Configuration 30 | ; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> 31 | ; 32 | 33 | Stack_Size EQU 0x00000400 34 | 35 | AREA STACK, NOINIT, READWRITE, ALIGN=3 36 | __stack_limit 37 | Stack_Mem SPACE Stack_Size 38 | __initial_sp 39 | 40 | 41 | ; Heap Configuration 42 | ; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> 43 | ; 44 | 45 | Heap_Size EQU 0x00000C00 46 | 47 | IF Heap_Size != 0 ; Heap is provided 48 | AREA HEAP, NOINIT, READWRITE, ALIGN=3 49 | __heap_base 50 | Heap_Mem SPACE Heap_Size 51 | __heap_limit 52 | ENDIF 53 | 54 | 55 | PRESERVE8 56 | THUMB 57 | 58 | 59 | ; Vector Table Mapped to Address 0 at Reset 60 | 61 | AREA RESET, DATA, READONLY 62 | EXPORT __Vectors 63 | EXPORT __Vectors_End 64 | EXPORT __Vectors_Size 65 | 66 | __Vectors DCD __initial_sp ; Top of Stack 67 | DCD Reset_Handler ; Reset Handler 68 | DCD NMI_Handler ; -14 NMI Handler 69 | DCD HardFault_Handler ; -13 Hard Fault Handler 70 | DCD MemManage_Handler ; -12 MPU Fault Handler 71 | DCD BusFault_Handler ; -11 Bus Fault Handler 72 | DCD UsageFault_Handler ; -10 Usage Fault Handler 73 | DCD 0 ; Reserved 74 | DCD 0 ; Reserved 75 | DCD 0 ; Reserved 76 | DCD 0 ; Reserved 77 | DCD SVC_Handler ; -5 SVCall Handler 78 | DCD DebugMon_Handler ; -4 Debug Monitor Handler 79 | DCD 0 ; Reserved 80 | DCD PendSV_Handler ; -2 PendSV Handler 81 | DCD SysTick_Handler ; -1 SysTick Handler 82 | 83 | ; Interrupts 84 | DCD Interrupt0_Handler ; 0 Interrupt 0 85 | DCD Interrupt1_Handler ; 1 Interrupt 1 86 | DCD Interrupt2_Handler ; 2 Interrupt 2 87 | DCD Interrupt3_Handler ; 3 Interrupt 3 88 | DCD Interrupt4_Handler ; 4 Interrupt 4 89 | DCD Interrupt5_Handler ; 5 Interrupt 5 90 | DCD Interrupt6_Handler ; 6 Interrupt 6 91 | DCD Interrupt7_Handler ; 7 Interrupt 7 92 | DCD Interrupt8_Handler ; 8 Interrupt 8 93 | DCD Interrupt9_Handler ; 9 Interrupt 9 94 | 95 | SPACE (214 * 4) ; Interrupts 10 .. 224 are left out 96 | __Vectors_End 97 | __Vectors_Size EQU __Vectors_End - __Vectors 98 | 99 | 100 | AREA |.text|, CODE, READONLY 101 | 102 | ; Reset Handler 103 | 104 | Reset_Handler PROC 105 | EXPORT Reset_Handler [WEAK] 106 | IMPORT SystemInit 107 | IMPORT __main 108 | 109 | LDR R0, =SystemInit 110 | BLX R0 111 | LDR R0, =__main 112 | BX R0 113 | ENDP 114 | 115 | ; The default macro is not used for HardFault_Handler 116 | ; because this results in a poor debug illusion. 117 | HardFault_Handler PROC 118 | EXPORT HardFault_Handler [WEAK] 119 | B . 120 | ENDP 121 | 122 | ; Macro to define default exception/interrupt handlers. 123 | ; Default handler are weak symbols with an endless loop. 124 | ; They can be overwritten by real handlers. 125 | MACRO 126 | Set_Default_Handler $Handler_Name 127 | $Handler_Name PROC 128 | EXPORT $Handler_Name [WEAK] 129 | B . 130 | ENDP 131 | MEND 132 | 133 | 134 | ; Default exception/interrupt handler 135 | 136 | Set_Default_Handler NMI_Handler 137 | Set_Default_Handler MemManage_Handler 138 | Set_Default_Handler BusFault_Handler 139 | Set_Default_Handler UsageFault_Handler 140 | Set_Default_Handler SVC_Handler 141 | Set_Default_Handler DebugMon_Handler 142 | Set_Default_Handler PendSV_Handler 143 | Set_Default_Handler SysTick_Handler 144 | 145 | Set_Default_Handler Interrupt0_Handler 146 | Set_Default_Handler Interrupt1_Handler 147 | Set_Default_Handler Interrupt2_Handler 148 | Set_Default_Handler Interrupt3_Handler 149 | Set_Default_Handler Interrupt4_Handler 150 | Set_Default_Handler Interrupt5_Handler 151 | Set_Default_Handler Interrupt6_Handler 152 | Set_Default_Handler Interrupt7_Handler 153 | Set_Default_Handler Interrupt8_Handler 154 | Set_Default_Handler Interrupt9_Handler 155 | 156 | ALIGN 157 | 158 | 159 | ; User setup Stack & Heap 160 | 161 | IF :LNOT::DEF:__MICROLIB 162 | IMPORT __use_two_region_memory 163 | ENDIF 164 | 165 | EXPORT __stack_limit 166 | EXPORT __initial_sp 167 | IF Heap_Size != 0 ; Heap is provided 168 | EXPORT __heap_base 169 | EXPORT __heap_limit 170 | ENDIF 171 | 172 | END 173 | -------------------------------------------------------------------------------- /example/RTE/Device/ARMCM3/system_ARMCM3.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file system_ARMCM3.c 3 | * @brief CMSIS Device System Source File for 4 | * ARMCM3 Device 5 | * @version V1.0.1 6 | * @date 15. November 2019 7 | ******************************************************************************/ 8 | /* 9 | * Copyright (c) 2009-2019 Arm Limited. All rights reserved. 10 | * 11 | * SPDX-License-Identifier: Apache-2.0 12 | * 13 | * Licensed under the Apache License, Version 2.0 (the License); you may 14 | * not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at 16 | * 17 | * www.apache.org/licenses/LICENSE-2.0 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 21 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | */ 25 | 26 | #include "ARMCM3.h" 27 | 28 | /*---------------------------------------------------------------------------- 29 | Define clocks 30 | *----------------------------------------------------------------------------*/ 31 | #define XTAL (50000000UL) /* Oscillator frequency */ 32 | 33 | #define SYSTEM_CLOCK (XTAL / 2U) 34 | 35 | /*---------------------------------------------------------------------------- 36 | Exception / Interrupt Vector table 37 | *----------------------------------------------------------------------------*/ 38 | 39 | /*---------------------------------------------------------------------------- 40 | System Core Clock Variable 41 | *----------------------------------------------------------------------------*/ 42 | uint32_t SystemCoreClock = SYSTEM_CLOCK; /* System Core Clock Frequency */ 43 | 44 | 45 | /*---------------------------------------------------------------------------- 46 | System Core Clock update function 47 | *----------------------------------------------------------------------------*/ 48 | void SystemCoreClockUpdate (void) 49 | { 50 | SystemCoreClock = SYSTEM_CLOCK; 51 | } 52 | 53 | /*---------------------------------------------------------------------------- 54 | System initialization function 55 | *----------------------------------------------------------------------------*/ 56 | void SystemInit (void) 57 | { 58 | 59 | SystemCoreClock = SYSTEM_CLOCK; 60 | } 61 | -------------------------------------------------------------------------------- /example/RTE/Device/CMSDK_CM0/RTE_Device.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * Copyright (c) 2016 ARM Ltd. 3 | * 4 | * This software is provided 'as-is', without any express or implied warranty. 5 | * In no event will the authors be held liable for any damages arising from 6 | * the use of this software. Permission is granted to anyone to use this 7 | * software for any purpose, including commercial applications, and to alter 8 | * it and redistribute it freely, subject to the following restrictions: 9 | * 10 | * 1. The origin of this software must not be misrepresented; you must not 11 | * claim that you wrote the original software. If you use this software in 12 | * a product, an acknowledgment in the product documentation would be 13 | * appreciated but is not required. 14 | * 15 | * 2. Altered source versions must be plainly marked as such, and must not be 16 | * misrepresented as being the original software. 17 | * 18 | * 3. This notice may not be removed or altered from any source distribution. 19 | * 20 | * $Date: 25. April 2016 21 | * $Revision: V1.0.0 22 | * 23 | * Project: RTE Device Configuration for ARM CMSDK_CM device 24 | * -------------------------------------------------------------------------- */ 25 | 26 | //-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- 27 | 28 | #ifndef __RTE_DEVICE_H 29 | #define __RTE_DEVICE_H 30 | 31 | // USART0 (Universal synchronous asynchronous receiver transmitter) [Driver_USART0] 32 | // Configuration settings for Driver_USART0 in component ::CMSIS Driver:USART 33 | #define RTE_USART0 1 34 | 35 | 36 | // USART1 (Universal synchronous asynchronous receiver transmitter) [Driver_USART1] 37 | // Configuration settings for Driver_USART1 in component ::CMSIS Driver:USART 38 | #define RTE_USART1 0 39 | 40 | 41 | // USART2 (Universal synchronous asynchronous receiver transmitter) [Driver_USART2] 42 | // Configuration settings for Driver_USART2 in component ::CMSIS Driver:USART 43 | #define RTE_UART2 0 44 | 45 | 46 | // USART3 (Universal synchronous asynchronous receiver transmitter) [Driver_USART3] 47 | // Configuration settings for Driver_USART3 in component ::CMSIS Driver:USART 48 | #define RTE_UART3 0 49 | 50 | #endif /* __RTE_DEVICE_H */ 51 | -------------------------------------------------------------------------------- /example/RTE/Device/CMSDK_CM0/system_CMSDK_CM0.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file system_CMSDK_CM0.c 3 | * @brief CMSIS Device System Source File for 4 | * CMSDK_M0 Device 5 | * @version V4.00 6 | * @date 02. November 2015 7 | ******************************************************************************/ 8 | /* Copyright (c) 2011 - 2015 ARM LIMITED 9 | 10 | All rights reserved. 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | - Redistributions of source code must retain the above copyright 14 | notice, this list of conditions and the following disclaimer. 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | - Neither the name of ARM nor the names of its contributors may be used 19 | to endorse or promote products derived from this software without 20 | specific prior written permission. 21 | * 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 26 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | POSSIBILITY OF SUCH DAMAGE. 33 | ---------------------------------------------------------------------------*/ 34 | 35 | 36 | #include "CMSDK_CM0.h" 37 | 38 | /*---------------------------------------------------------------------------- 39 | Define clocks 40 | *----------------------------------------------------------------------------*/ 41 | #define XTAL (50000000UL) /* Oscillator frequency */ 42 | 43 | #define SYSTEM_CLOCK (XTAL / 2) 44 | 45 | 46 | /*---------------------------------------------------------------------------- 47 | System Core Clock Variable 48 | *----------------------------------------------------------------------------*/ 49 | uint32_t SystemCoreClock = SYSTEM_CLOCK; /* System Core Clock Frequency */ 50 | 51 | 52 | void SystemCoreClockUpdate (void) 53 | { 54 | SystemCoreClock = SYSTEM_CLOCK; 55 | } 56 | 57 | void SystemInit (void) 58 | { 59 | SystemCoreClock = SYSTEM_CLOCK; 60 | } 61 | -------------------------------------------------------------------------------- /example/RTE/Device/CMSDK_CM3/RTE_Device.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * Copyright (c) 2016 ARM Ltd. 3 | * 4 | * This software is provided 'as-is', without any express or implied warranty. 5 | * In no event will the authors be held liable for any damages arising from 6 | * the use of this software. Permission is granted to anyone to use this 7 | * software for any purpose, including commercial applications, and to alter 8 | * it and redistribute it freely, subject to the following restrictions: 9 | * 10 | * 1. The origin of this software must not be misrepresented; you must not 11 | * claim that you wrote the original software. If you use this software in 12 | * a product, an acknowledgment in the product documentation would be 13 | * appreciated but is not required. 14 | * 15 | * 2. Altered source versions must be plainly marked as such, and must not be 16 | * misrepresented as being the original software. 17 | * 18 | * 3. This notice may not be removed or altered from any source distribution. 19 | * 20 | * $Date: 25. April 2016 21 | * $Revision: V1.0.0 22 | * 23 | * Project: RTE Device Configuration for ARM CMSDK_CM device 24 | * -------------------------------------------------------------------------- */ 25 | 26 | //-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- 27 | 28 | #ifndef __RTE_DEVICE_H 29 | #define __RTE_DEVICE_H 30 | 31 | // USART0 (Universal synchronous asynchronous receiver transmitter) [Driver_USART0] 32 | // Configuration settings for Driver_USART0 in component ::CMSIS Driver:USART 33 | #define RTE_USART0 1 34 | 35 | 36 | // USART1 (Universal synchronous asynchronous receiver transmitter) [Driver_USART1] 37 | // Configuration settings for Driver_USART1 in component ::CMSIS Driver:USART 38 | #define RTE_USART1 0 39 | 40 | 41 | // USART2 (Universal synchronous asynchronous receiver transmitter) [Driver_USART2] 42 | // Configuration settings for Driver_USART2 in component ::CMSIS Driver:USART 43 | #define RTE_UART2 0 44 | 45 | 46 | // USART3 (Universal synchronous asynchronous receiver transmitter) [Driver_USART3] 47 | // Configuration settings for Driver_USART3 in component ::CMSIS Driver:USART 48 | #define RTE_UART3 0 49 | 50 | #endif /* __RTE_DEVICE_H */ 51 | -------------------------------------------------------------------------------- /example/RTE/Device/CMSDK_CM3/system_CMSDK_CM3.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file system_CMSDK_CM3.c 3 | * @brief CMSIS Device System Source File for 4 | * CMSDK_M3 Device 5 | * @version V4.00 6 | * @date 02. November 2015 7 | ******************************************************************************/ 8 | /* Copyright (c) 2011 - 2015 ARM LIMITED 9 | 10 | All rights reserved. 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | - Redistributions of source code must retain the above copyright 14 | notice, this list of conditions and the following disclaimer. 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | - Neither the name of ARM nor the names of its contributors may be used 19 | to endorse or promote products derived from this software without 20 | specific prior written permission. 21 | * 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 26 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | POSSIBILITY OF SUCH DAMAGE. 33 | ---------------------------------------------------------------------------*/ 34 | 35 | 36 | #include "CMSDK_CM3.h" 37 | 38 | /*---------------------------------------------------------------------------- 39 | Define clocks 40 | *----------------------------------------------------------------------------*/ 41 | #define XTAL (50000000UL) /* Oscillator frequency */ 42 | 43 | #define SYSTEM_CLOCK (XTAL / 2) 44 | 45 | 46 | /*---------------------------------------------------------------------------- 47 | System Core Clock Variable 48 | *----------------------------------------------------------------------------*/ 49 | uint32_t SystemCoreClock = SYSTEM_CLOCK; /* System Core Clock Frequency */ 50 | 51 | 52 | void SystemCoreClockUpdate (void) 53 | { 54 | SystemCoreClock = SYSTEM_CLOCK; 55 | } 56 | 57 | void SystemInit (void) 58 | { 59 | 60 | #ifdef UNALIGNED_SUPPORT_DISABLE 61 | SCB->CCR |= SCB_CCR_UNALIGN_TRP_Msk; 62 | #endif 63 | 64 | SystemCoreClock = SYSTEM_CLOCK; 65 | } 66 | -------------------------------------------------------------------------------- /example/RTE/Device/CMSDK_CM7_SP/RTE_Device.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------------- 2 | * Copyright (c) 2016 ARM Ltd. 3 | * 4 | * This software is provided 'as-is', without any express or implied warranty. 5 | * In no event will the authors be held liable for any damages arising from 6 | * the use of this software. Permission is granted to anyone to use this 7 | * software for any purpose, including commercial applications, and to alter 8 | * it and redistribute it freely, subject to the following restrictions: 9 | * 10 | * 1. The origin of this software must not be misrepresented; you must not 11 | * claim that you wrote the original software. If you use this software in 12 | * a product, an acknowledgment in the product documentation would be 13 | * appreciated but is not required. 14 | * 15 | * 2. Altered source versions must be plainly marked as such, and must not be 16 | * misrepresented as being the original software. 17 | * 18 | * 3. This notice may not be removed or altered from any source distribution. 19 | * 20 | * $Date: 25. April 2016 21 | * $Revision: V1.0.0 22 | * 23 | * Project: RTE Device Configuration for ARM CMSDK_CM device 24 | * -------------------------------------------------------------------------- */ 25 | 26 | //-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- 27 | 28 | #ifndef __RTE_DEVICE_H 29 | #define __RTE_DEVICE_H 30 | 31 | // USART0 (Universal synchronous asynchronous receiver transmitter) [Driver_USART0] 32 | // Configuration settings for Driver_USART0 in component ::CMSIS Driver:USART 33 | #define RTE_USART0 1 34 | 35 | 36 | // USART1 (Universal synchronous asynchronous receiver transmitter) [Driver_USART1] 37 | // Configuration settings for Driver_USART1 in component ::CMSIS Driver:USART 38 | #define RTE_USART1 0 39 | 40 | 41 | // USART2 (Universal synchronous asynchronous receiver transmitter) [Driver_USART2] 42 | // Configuration settings for Driver_USART2 in component ::CMSIS Driver:USART 43 | #define RTE_UART2 0 44 | 45 | 46 | // USART3 (Universal synchronous asynchronous receiver transmitter) [Driver_USART3] 47 | // Configuration settings for Driver_USART3 in component ::CMSIS Driver:USART 48 | #define RTE_UART3 0 49 | 50 | #endif /* __RTE_DEVICE_H */ 51 | -------------------------------------------------------------------------------- /example/RTE/Device/CMSDK_CM7_SP/system_CMSDK_CM7.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file system_CMSDK_CM7.c 3 | * @brief CMSIS Device System Source File for 4 | * CMSDK_CM7 Device 5 | * @version V4.00 6 | * @date 02. November 2015 7 | ******************************************************************************/ 8 | /* Copyright (c) 2011 - 2015 ARM LIMITED 9 | 10 | All rights reserved. 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | - Redistributions of source code must retain the above copyright 14 | notice, this list of conditions and the following disclaimer. 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | - Neither the name of ARM nor the names of its contributors may be used 19 | to endorse or promote products derived from this software without 20 | specific prior written permission. 21 | * 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 26 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | POSSIBILITY OF SUCH DAMAGE. 33 | ---------------------------------------------------------------------------*/ 34 | 35 | 36 | #if defined (CMSDK_CM7) 37 | #include "CMSDK_CM7.h" 38 | #elif defined (CMSDK_CM7_SP) 39 | #include "CMSDK_CM7_SP.h" 40 | #elif defined (CMSDK_CM7_DP) 41 | #include "CMSDK_CM7_DP.h" 42 | #else 43 | #error device not specified! 44 | #endif 45 | 46 | /*---------------------------------------------------------------------------- 47 | Define clocks 48 | *----------------------------------------------------------------------------*/ 49 | #define XTAL (50000000UL) /* Oscillator frequency */ 50 | 51 | #define SYSTEM_CLOCK (XTAL / 2) 52 | 53 | 54 | /*---------------------------------------------------------------------------- 55 | System Core Clock Variable 56 | *----------------------------------------------------------------------------*/ 57 | uint32_t SystemCoreClock = SYSTEM_CLOCK; /* System Core Clock Frequency */ 58 | 59 | 60 | void SystemCoreClockUpdate (void) 61 | { 62 | SystemCoreClock = SYSTEM_CLOCK; 63 | } 64 | 65 | void SystemInit (void) 66 | { 67 | #if (__FPU_USED == 1) 68 | SCB->CPACR |= ((3UL << 10*2) | /* set CP10 Full Access */ 69 | (3UL << 11*2) ); /* set CP11 Full Access */ 70 | #endif 71 | 72 | #ifdef UNALIGNED_SUPPORT_DISABLE 73 | SCB->CCR |= SCB_CCR_UNALIGN_TRP_Msk; 74 | #endif 75 | 76 | SystemCoreClock = SYSTEM_CLOCK; 77 | } 78 | -------------------------------------------------------------------------------- /example/RTE/RTOS/board.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006-2022, RT-Thread Development Team 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Change Logs: 7 | * Date Author Notes 8 | * 2017-07-24 Tanek the first version 9 | * 2018-11-12 Ernest Chen modify copyright 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #define _SCB_BASE (0xE000E010UL) 17 | #define _SYSTICK_CTRL (*(rt_uint32_t *)(_SCB_BASE + 0x0)) 18 | #define _SYSTICK_LOAD (*(rt_uint32_t *)(_SCB_BASE + 0x4)) 19 | #define _SYSTICK_VAL (*(rt_uint32_t *)(_SCB_BASE + 0x8)) 20 | #define _SYSTICK_CALIB (*(rt_uint32_t *)(_SCB_BASE + 0xC)) 21 | #define _SYSTICK_PRI (*(rt_uint8_t *)(0xE000ED23UL)) 22 | 23 | // Updates the variable SystemCoreClock and must be called 24 | // whenever the core clock is changed during program execution. 25 | extern void SystemCoreClockUpdate(void); 26 | 27 | // Holds the system core clock, which is the system clock 28 | // frequency supplied to the SysTick timer and the processor 29 | // core clock. 30 | extern uint32_t SystemCoreClock; 31 | 32 | static uint32_t _SysTick_Config(rt_uint32_t ticks) 33 | { 34 | if ((ticks - 1) > 0xFFFFFF) 35 | { 36 | return 1; 37 | } 38 | 39 | _SYSTICK_LOAD = ticks - 1; 40 | _SYSTICK_PRI = 0xFF; 41 | _SYSTICK_VAL = 0; 42 | _SYSTICK_CTRL = 0x07; 43 | 44 | return 0; 45 | } 46 | 47 | #if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP) 48 | #define RT_HEAP_SIZE 1024 49 | static uint32_t rt_heap[RT_HEAP_SIZE]; // heap default size: 4K(1024 * 4) 50 | RT_WEAK void *rt_heap_begin_get(void) 51 | { 52 | return rt_heap; 53 | } 54 | 55 | RT_WEAK void *rt_heap_end_get(void) 56 | { 57 | return rt_heap + RT_HEAP_SIZE; 58 | } 59 | #endif 60 | 61 | /** 62 | * This function will initial your board. 63 | */ 64 | void rt_hw_board_init() 65 | { 66 | /* System Clock Update */ 67 | SystemCoreClockUpdate(); 68 | 69 | /* System Tick Configuration */ 70 | _SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND); 71 | 72 | /* Call components board initial (use INIT_BOARD_EXPORT()) */ 73 | #ifdef RT_USING_COMPONENTS_INIT 74 | rt_components_board_init(); 75 | #endif 76 | 77 | #if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP) 78 | rt_system_heap_init(rt_heap_begin_get(), rt_heap_end_get()); 79 | #endif 80 | } 81 | 82 | void SysTick_Handler(void) 83 | { 84 | /* enter interrupt */ 85 | rt_interrupt_enter(); 86 | 87 | rt_tick_increase(); 88 | 89 | /* leave interrupt */ 90 | rt_interrupt_leave(); 91 | } 92 | -------------------------------------------------------------------------------- /example/RTE/RTOS/rtconfig.h: -------------------------------------------------------------------------------- 1 | /* RT-Thread config file */ 2 | 3 | #ifndef __RTTHREAD_CFG_H__ 4 | #define __RTTHREAD_CFG_H__ 5 | 6 | #if defined(__CC_ARM) || defined(__CLANG_ARM) 7 | #include "RTE_Components.h" 8 | 9 | #if defined(RTE_USING_FINSH) 10 | #define RT_USING_FINSH 11 | #endif //RTE_USING_FINSH 12 | 13 | #endif //(__CC_ARM) || (__CLANG_ARM) 14 | 15 | // <<< Use Configuration Wizard in Context Menu >>> 16 | // Basic Configuration 17 | // Maximal level of thread priority <8-256> 18 | // Default: 32 19 | #define RT_THREAD_PRIORITY_MAX 8 20 | // OS tick per second 21 | // Default: 1000 (1ms) 22 | #define RT_TICK_PER_SECOND 1000 23 | // Alignment size for CPU architecture data access 24 | // Default: 4 25 | #define RT_ALIGN_SIZE 4 26 | // the max length of object name<2-16> 27 | // Default: 8 28 | #define RT_NAME_MAX 8 29 | // Using RT-Thread components initialization 30 | // Using RT-Thread components initialization 31 | #define RT_USING_COMPONENTS_INIT 32 | // 33 | 34 | #define RT_USING_USER_MAIN 35 | 36 | // the stack size of main thread<1-4086> 37 | // Default: 512 38 | #define RT_MAIN_THREAD_STACK_SIZE 256 39 | 40 | // 41 | 42 | // Debug Configuration 43 | // enable kernel debug configuration 44 | // Default: enable kernel debug configuration 45 | //#define RT_DEBUG 46 | // 47 | // enable components initialization debug configuration<0-1> 48 | // Default: 0 49 | #define RT_DEBUG_INIT 0 50 | // thread stack over flow detect 51 | // Diable Thread stack over flow detect 52 | //#define RT_USING_OVERFLOW_CHECK 53 | // 54 | // 55 | 56 | // Hook Configuration 57 | // using hook 58 | // using hook 59 | //#define RT_USING_HOOK 60 | // 61 | // using idle hook 62 | // using idle hook 63 | //#define RT_USING_IDLE_HOOK 64 | // 65 | // 66 | 67 | // Software timers Configuration 68 | // Enables user timers 69 | #define RT_USING_TIMER_SOFT 0 70 | #if RT_USING_TIMER_SOFT == 0 71 | #undef RT_USING_TIMER_SOFT 72 | #endif 73 | // The priority level of timer thread <0-31> 74 | // Default: 4 75 | #define RT_TIMER_THREAD_PRIO 4 76 | // The stack size of timer thread <0-8192> 77 | // Default: 512 78 | #define RT_TIMER_THREAD_STACK_SIZE 512 79 | // 80 | 81 | // IPC(Inter-process communication) Configuration 82 | // Using Semaphore 83 | // Using Semaphore 84 | #define RT_USING_SEMAPHORE 85 | // 86 | // Using Mutex 87 | // Using Mutex 88 | //#define RT_USING_MUTEX 89 | // 90 | // Using Event 91 | // Using Event 92 | //#define RT_USING_EVENT 93 | // 94 | // Using MailBox 95 | // Using MailBox 96 | #define RT_USING_MAILBOX 97 | // 98 | // Using Message Queue 99 | // Using Message Queue 100 | //#define RT_USING_MESSAGEQUEUE 101 | // 102 | // 103 | 104 | // Memory Management Configuration 105 | // Dynamic Heap Management 106 | // Dynamic Heap Management 107 | //#define RT_USING_HEAP 108 | // 109 | // using small memory 110 | // using small memory 111 | #define RT_USING_SMALL_MEM 112 | // 113 | // using tiny size of memory 114 | // using tiny size of memory 115 | //#define RT_USING_TINY_SIZE 116 | // 117 | // 118 | 119 | // Console Configuration 120 | // Using console 121 | // Using console 122 | #define RT_USING_CONSOLE 123 | // 124 | // the buffer size of console <1-1024> 125 | // the buffer size of console 126 | // Default: 128 (128Byte) 127 | #define RT_CONSOLEBUF_SIZE 128 128 | // 129 | 130 | #if defined(RT_USING_FINSH) 131 | #define FINSH_USING_MSH 132 | #define FINSH_USING_MSH_ONLY 133 | // Finsh Configuration 134 | // the priority of finsh thread <1-7> 135 | // the priority of finsh thread 136 | // Default: 6 137 | #define __FINSH_THREAD_PRIORITY 5 138 | #define FINSH_THREAD_PRIORITY (RT_THREAD_PRIORITY_MAX / 8 * __FINSH_THREAD_PRIORITY + 1) 139 | // the stack of finsh thread <1-4096> 140 | // the stack of finsh thread 141 | // Default: 4096 (4096Byte) 142 | #define FINSH_THREAD_STACK_SIZE 512 143 | // the history lines of finsh thread <1-32> 144 | // the history lines of finsh thread 145 | // Default: 5 146 | #define FINSH_HISTORY_LINES 1 147 | 148 | #define FINSH_USING_SYMTAB 149 | // 150 | #endif 151 | 152 | // <<< end of configuration section >>> 153 | 154 | #endif 155 | -------------------------------------------------------------------------------- /example/copy.bat: -------------------------------------------------------------------------------- 1 | @copy /B /Y .\Out\*.lib ..\lib\ 2 | @copy /B /Y .\GCC_Out\*.a ..\lib\ 3 | @copy /B /Y ..\perf_counter.h ..\lib\ -------------------------------------------------------------------------------- /example/example.sct: -------------------------------------------------------------------------------- 1 | #! armclang --target=arm-arm-none-eabi -mcpu=cortex-m0 -E -xc 2 | ; ************************************************************* 3 | ; *** Scatter-Loading Description File generated by uVision *** 4 | ; ************************************************************* 5 | 6 | 7 | #define RAM1_SIZE 0x00020000 8 | #define RAM1_BASE 0x20000000 9 | #define RAM1_LIMIT (RAM1_BASE + RAM1_SIZE) 10 | 11 | #define STACK_SIZE 0x1000 12 | 13 | #define HEAP_ALIGN 8 14 | #define HEAP_SIZE (RAM1_LIMIT - AlignExpr(ImageLimit(ZI_RAM_UNINIT), HEAP_ALIGN)) 15 | 16 | 17 | LR_IROM1 0x00000000 0x00040000 { ; load region size_region 18 | ER_IROM1 0x00000000 0x00040000 { ; load address = execution address 19 | *.o (RESET, +First) 20 | *(InRoot$$Sections) 21 | .ANY (+RO) 22 | .ANY (+XO) 23 | } 24 | 25 | ARM_LIB_STACK RAM1_BASE ALIGN 8 EMPTY FILL 0xDEADBEEF STACK_SIZE {} 26 | 27 | RW_IRAM1 +0 { ; RW data 28 | .ANY (+RW +ZI) 29 | } 30 | 31 | ZI_RAM_UNINIT +0 UNINIT { 32 | .ANY (.bss.noinit) 33 | } 34 | 35 | ARM_LIB_HEAP +0 ALIGN HEAP_ALIGN EMPTY HEAP_SIZE {} 36 | 37 | ScatterAssert(ImageLimit(ARM_LIB_HEAP) <= RAM1_LIMIT) 38 | } 39 | 40 | 41 | -------------------------------------------------------------------------------- /example/example.uvmpw: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1.0 5 | 6 |
### uVision Project, (C) Keil Software
7 | 8 | Y:\Work\git\perf_counter\example\example.uvmpw 9 | 10 | 11 | .\example.uvprojx 12 | 1 13 | 1 14 | 15 | 16 | 17 | .\gcc_example.uvprojx 18 | 19 | 20 |
21 | -------------------------------------------------------------------------------- /example/gcc/gcc_arm.ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GorgonMeducer/perf_counter/3dfee7d3f4b201b7b857fb1445800b251d9f27e5/example/gcc/gcc_arm.ld -------------------------------------------------------------------------------- /example/gcc/startup_ARMCM0.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file startup_ARMCM0.c 3 | * @brief CMSIS-Core(M) Device Startup File for a Cortex-M0 Device 4 | * @version V2.0.3 5 | * @date 31. March 2020 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2020 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | 26 | #include "ARMCM0.h" 27 | 28 | /*---------------------------------------------------------------------------- 29 | External References 30 | *----------------------------------------------------------------------------*/ 31 | extern uint32_t __INITIAL_SP; 32 | 33 | extern __NO_RETURN void __PROGRAM_START(void); 34 | 35 | /*---------------------------------------------------------------------------- 36 | Internal References 37 | *----------------------------------------------------------------------------*/ 38 | __NO_RETURN void Reset_Handler (void); 39 | void Default_Handler(void); 40 | 41 | /*---------------------------------------------------------------------------- 42 | Exception / Interrupt Handler 43 | *----------------------------------------------------------------------------*/ 44 | /* Exceptions */ 45 | void NMI_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 46 | void HardFault_Handler (void) __attribute__ ((weak)); 47 | void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 48 | void PendSV_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 49 | void SysTick_Handler (void) __attribute__ ((weak)); 50 | 51 | void Interrupt0_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 52 | void Interrupt1_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 53 | void Interrupt2_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 54 | void Interrupt3_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 55 | void Interrupt4_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 56 | void Interrupt5_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 57 | void Interrupt6_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 58 | void Interrupt7_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 59 | void Interrupt8_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 60 | void Interrupt9_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); 61 | 62 | 63 | /*---------------------------------------------------------------------------- 64 | Exception / Interrupt Vector table 65 | *----------------------------------------------------------------------------*/ 66 | 67 | #if defined ( __GNUC__ ) 68 | #pragma GCC diagnostic push 69 | #pragma GCC diagnostic ignored "-Wpedantic" 70 | #endif 71 | 72 | extern const VECTOR_TABLE_Type __VECTOR_TABLE[48]; 73 | const VECTOR_TABLE_Type __VECTOR_TABLE[48] __VECTOR_TABLE_ATTRIBUTE = { 74 | (VECTOR_TABLE_Type)(&__INITIAL_SP), /* Initial Stack Pointer */ 75 | Reset_Handler, /* Reset Handler */ 76 | NMI_Handler, /* -14 NMI Handler */ 77 | HardFault_Handler, /* -13 Hard Fault Handler */ 78 | 0, /* Reserved */ 79 | 0, /* Reserved */ 80 | 0, /* Reserved */ 81 | 0, /* Reserved */ 82 | 0, /* Reserved */ 83 | 0, /* Reserved */ 84 | 0, /* Reserved */ 85 | SVC_Handler, /* -5 SVCall Handler */ 86 | 0, /* Reserved */ 87 | 0, /* Reserved */ 88 | PendSV_Handler, /* -2 PendSV Handler */ 89 | SysTick_Handler, /* -1 SysTick Handler */ 90 | 91 | /* Interrupts */ 92 | Interrupt0_Handler, /* 0 Interrupt 0 */ 93 | Interrupt1_Handler, /* 1 Interrupt 1 */ 94 | Interrupt2_Handler, /* 2 Interrupt 2 */ 95 | Interrupt3_Handler, /* 3 Interrupt 3 */ 96 | Interrupt4_Handler, /* 4 Interrupt 4 */ 97 | Interrupt5_Handler, /* 5 Interrupt 5 */ 98 | Interrupt6_Handler, /* 6 Interrupt 6 */ 99 | Interrupt7_Handler, /* 7 Interrupt 7 */ 100 | Interrupt8_Handler, /* 8 Interrupt 8 */ 101 | Interrupt9_Handler /* 9 Interrupt 9 */ 102 | /* Interrupts 10..31 are left out */ 103 | }; 104 | 105 | #if defined ( __GNUC__ ) 106 | #pragma GCC diagnostic pop 107 | #endif 108 | 109 | /*---------------------------------------------------------------------------- 110 | Reset Handler called on controller reset 111 | *----------------------------------------------------------------------------*/ 112 | __NO_RETURN void Reset_Handler(void) 113 | { 114 | SystemInit(); /* CMSIS System Initialization */ 115 | __PROGRAM_START(); /* Enter PreMain (C library entry point) */ 116 | } 117 | 118 | 119 | #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 120 | #pragma clang diagnostic push 121 | #pragma clang diagnostic ignored "-Wmissing-noreturn" 122 | #endif 123 | 124 | /*---------------------------------------------------------------------------- 125 | Hard Fault Handler 126 | *----------------------------------------------------------------------------*/ 127 | void HardFault_Handler(void) 128 | { 129 | while(1); 130 | } 131 | 132 | 133 | 134 | /*---------------------------------------------------------------------------- 135 | Default Handler for Exceptions / Interrupts 136 | *----------------------------------------------------------------------------*/ 137 | void Default_Handler(void) 138 | { 139 | while(1); 140 | } 141 | 142 | #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 143 | #pragma clang diagnostic pop 144 | #endif 145 | 146 | -------------------------------------------------------------------------------- /example/gcc/system_ARMCM0.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file system_ARMCM0.c 3 | * @brief CMSIS Device System Source File for 4 | * ARMCM0 Device 5 | * @version V1.0.0 6 | * @date 09. July 2018 7 | ******************************************************************************/ 8 | /* 9 | * Copyright (c) 2009-2018 Arm Limited. All rights reserved. 10 | * 11 | * SPDX-License-Identifier: Apache-2.0 12 | * 13 | * Licensed under the Apache License, Version 2.0 (the License); you may 14 | * not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at 16 | * 17 | * www.apache.org/licenses/LICENSE-2.0 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 21 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | */ 25 | 26 | #include "ARMCM0.h" 27 | 28 | /*---------------------------------------------------------------------------- 29 | Define clocks 30 | *----------------------------------------------------------------------------*/ 31 | #define XTAL (50000000UL) /* Oscillator frequency */ 32 | 33 | #define SYSTEM_CLOCK (XTAL / 2U) 34 | 35 | 36 | /*---------------------------------------------------------------------------- 37 | System Core Clock Variable 38 | *----------------------------------------------------------------------------*/ 39 | uint32_t SystemCoreClock = SYSTEM_CLOCK; /* System Core Clock Frequency */ 40 | 41 | 42 | /*---------------------------------------------------------------------------- 43 | System Core Clock update function 44 | *----------------------------------------------------------------------------*/ 45 | void SystemCoreClockUpdate (void) 46 | { 47 | SystemCoreClock = SYSTEM_CLOCK; 48 | } 49 | 50 | /*---------------------------------------------------------------------------- 51 | System initialization function 52 | *----------------------------------------------------------------------------*/ 53 | void SystemInit (void) 54 | { 55 | SystemCoreClock = SYSTEM_CLOCK; 56 | } 57 | -------------------------------------------------------------------------------- /example/main.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright 2021 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) * 3 | * * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); * 5 | * you may not use this file except in compliance with the License. * 6 | * You may obtain a copy of the License at * 7 | * * 8 | * http://www.apache.org/licenses/LICENSE-2.0 * 9 | * * 10 | * Unless required by applicable law or agreed to in writing, software * 11 | * distributed under the License is distributed on an "AS IS" BASIS, * 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 13 | * See the License for the specific language governing permissions and * 14 | * limitations under the License. * 15 | * * 16 | ****************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "perf_counter.h" 22 | #include 23 | 24 | 25 | #ifndef __PERF_CNT_USE_LONG_CLOCK__ 26 | #include 27 | #else 28 | typedef int64_t clock_t ; 29 | #endif 30 | 31 | extern void systimer_1ms_handler(void); 32 | 33 | void systimer_1ms_handler(void) 34 | { 35 | //printf("Running original Systick_Handler...\r\n"); 36 | } 37 | 38 | typedef struct example_lv1_t { 39 | uint32_t wLV1A; 40 | uint16_t hwLV1B; 41 | uint8_t chLV1C; 42 | uint8_t chLV1D; 43 | }example_lv1_t; 44 | 45 | 46 | typedef struct example_lv0_t { 47 | 48 | uint32_t wA; 49 | uint16_t hwB; 50 | uint8_t chC; 51 | uint8_t chID; 52 | example_lv1_t tLV1; 53 | } example_lv0_t; 54 | 55 | 56 | static example_lv0_t s_tItem[8] = { 57 | {.chID = 0}, 58 | {.chID = 1}, 59 | {.chID = 2}, 60 | {.chID = 3}, 61 | {.chID = 4}, 62 | {.chID = 5}, 63 | {.chID = 6}, 64 | {.chID = 7}, 65 | }; 66 | #if __IS_COMPILER_ARM_COMPILER__ 67 | #if defined(__clang__) 68 | # pragma clang diagnostic push 69 | # pragma clang diagnostic ignored "-Wdollar-in-identifier-extension" 70 | # pragma clang diagnostic ignored "-Wdouble-promotion" 71 | #endif 72 | uint32_t calculate_stack_usage_topdown(void) 73 | { 74 | extern uint32_t Image$$ARM_LIB_STACK$$Limit[]; 75 | extern uint32_t Image$$ARM_LIB_STACK$$Length; 76 | 77 | uint32_t *pwStack = Image$$ARM_LIB_STACK$$Limit; 78 | uint32_t wStackSize = (uintptr_t)&Image$$ARM_LIB_STACK$$Length / 4; 79 | uint32_t wStackUsed = 0; 80 | 81 | 82 | do { 83 | if (*--pwStack == 0xDEADBEEF) { 84 | break; 85 | } 86 | wStackUsed++; 87 | } while(--wStackSize); 88 | 89 | 90 | printf("\r\nStack Usage: [%d/%d] %2.2f%%\r\n", 91 | wStackUsed * 4, 92 | (uintptr_t)&Image$$ARM_LIB_STACK$$Length, 93 | ( (float)wStackUsed * 400.0f 94 | / (float)(uintptr_t)&Image$$ARM_LIB_STACK$$Length)); 95 | 96 | return wStackUsed * 4; 97 | } 98 | 99 | uint32_t calculate_stack_usage_bottomup(void) 100 | { 101 | extern uint32_t Image$$ARM_LIB_STACK$$Base[]; 102 | extern uint32_t Image$$ARM_LIB_STACK$$Length; 103 | 104 | uint32_t *pwStack = Image$$ARM_LIB_STACK$$Base; 105 | uint32_t wStackSize = (uintptr_t)&Image$$ARM_LIB_STACK$$Length; 106 | uint32_t wStackUsed = wStackSize / 4; 107 | 108 | do { 109 | if (*pwStack++ != 0xDEADBEEF) { 110 | break; 111 | } 112 | } while(--wStackUsed); 113 | 114 | printf("\r\nStack Usage: [%d/%d] %2.2f%%\r\n", 115 | wStackUsed * 4, 116 | wStackSize, 117 | ( (float)wStackUsed * 400.0f / (float)wStackSize)); 118 | 119 | return wStackUsed * 4; 120 | } 121 | 122 | #if defined(__clang__) 123 | # pragma clang diagnostic pop 124 | #endif 125 | #endif 126 | 127 | /*---------------------------------------------------------------------------- 128 | Main function 129 | *----------------------------------------------------------------------------*/ 130 | 131 | typedef struct { 132 | uint8_t chPT; 133 | void *ptResource; 134 | } pt_led_flash_cb_t; 135 | 136 | #undef this 137 | #define this (*ptThis) 138 | 139 | fsm_rt_t pt_example_led_flash(pt_led_flash_cb_t *ptThis) 140 | { 141 | 142 | PERFC_PT_BEGIN(this.chPT) 143 | 144 | do { 145 | 146 | PERFC_PT_WAIT_RESOURCE_UNTIL( 147 | (this.ptResource != NULL), /* quit condition */ 148 | this.ptResource = malloc(100); /* try to allocate memory */ 149 | ) 150 | 151 | printf("LED ON [%lld]\r\n", get_system_ms()); 152 | 153 | PERFC_PT_DELAY_MS(500); 154 | 155 | printf("LED OFF [%lld]\r\n", get_system_ms()); 156 | 157 | PERFC_PT_DELAY_MS(500); 158 | 159 | free(this.ptResource); 160 | 161 | } while(1); 162 | 163 | PERFC_PT_END() 164 | 165 | return fsm_rt_cpl; 166 | 167 | } 168 | 169 | static pt_led_flash_cb_t s_tExamplePT = {0}; 170 | 171 | int main (void) 172 | { 173 | int32_t iCycleResult = 0; 174 | 175 | /*! demo of using() block */ 176 | using(int a = 0,printf("========= On Enter =======\r\n"), 177 | printf("========= On Leave =======\r\n")) { 178 | printf("\t In Body a=%d \r\n", ++a); 179 | } 180 | 181 | __cycleof__("Calibration") {} 182 | 183 | printf("\r\n\r\n\r\n\r\n"); 184 | 185 | /*! demo of __cycleof__() operation */ 186 | __cycleof__() { 187 | foreach(s_tItem) { 188 | printf("Processing item with ID = %d\r\n", _->chID); 189 | } 190 | } 191 | 192 | /* measure cycles and store it in a dedicated variable without printf */ 193 | __cycleof__("delay_us(1000ul)", 194 | /* insert code to __cycleof__ body, "{}" can be omitted */ 195 | { 196 | iCycleResult = __cycle_count__; /*< "__cycle_count__" stores the result */ 197 | }) { 198 | delay_us(1000ul); 199 | } 200 | 201 | printf("\r\n delay_us(1000ul) takes %d cycles\r\n", (int)iCycleResult); 202 | 203 | /*! demo of with block */ 204 | with(example_lv0_t, &s_tItem[0], pitem) { 205 | _->wA = 1; 206 | _->hwB = 2; 207 | _->chC = 3; 208 | 209 | with(&pitem->tLV1) { 210 | _->wLV1A = 4; 211 | _->hwLV1B = 5; 212 | _->chLV1C = 6; 213 | } 214 | } 215 | 216 | //! demo of using clock() in timer.h 217 | do { 218 | int64_t tStart = get_system_ticks(); 219 | __IRQ_SAFE { 220 | printf("no interrupt \r\n"); 221 | } 222 | printf("used clock cycle: %d", (int32_t)(get_system_ticks() - tStart)); 223 | } while(0); 224 | 225 | #if __IS_COMPILER_ARM_COMPILER__ 226 | calculate_stack_usage_topdown(); 227 | calculate_stack_usage_bottomup(); 228 | #endif 229 | 230 | #ifdef __PERF_COUNTER_COREMARK__ 231 | coremark_main(); 232 | #endif 233 | 234 | while (1) { 235 | if (perfc_is_time_out_ms(10000)) { 236 | printf("\r[%010lld]", get_system_ms()); 237 | } 238 | 239 | __cpu_usage__(10) { 240 | delay_us(30000); 241 | } 242 | 243 | float fUsage = 0; 244 | __cpu_usage__(10, { 245 | fUsage = __usage__; 246 | printf("task 1 cpu usage %3.2f %%\r\n", (double)fUsage); 247 | }) { 248 | delay_us(50000); 249 | } 250 | 251 | delay_us(20000); 252 | 253 | pt_example_led_flash(&s_tExamplePT); 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /example/platform.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright 2021 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) * 3 | * * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); * 5 | * you may not use this file except in compliance with the License. * 6 | * You may obtain a copy of the License at * 7 | * * 8 | * http://www.apache.org/licenses/LICENSE-2.0 * 9 | * * 10 | * Unless required by applicable law or agreed to in writing, software * 11 | * distributed under the License is distributed on an "AS IS" BASIS, * 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 13 | * See the License for the specific language governing permissions and * 14 | * limitations under the License. * 15 | * * 16 | ****************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include 21 | #include "perf_counter.h" 22 | #include "ARMCM0.h" // Keil::Board Support:V2M-MPS2:Common 23 | #include 24 | #include 25 | #if defined(RTE_Compiler_EventRecorder) 26 | # include 27 | #endif 28 | 29 | extern 30 | void uart_config(uint32_t wUARTFrequency); 31 | 32 | 33 | __attribute__((weak)) 34 | void systimer_1ms_handler(void) 35 | { 36 | //assert(false); 37 | } 38 | 39 | static volatile uint32_t s_wMSCounter = 0; 40 | 41 | /*---------------------------------------------------------------------------- 42 | SysTick / Timer0 IRQ Handler 43 | *----------------------------------------------------------------------------*/ 44 | 45 | void SysTick_Handler (void) 46 | { 47 | if (s_wMSCounter) { 48 | s_wMSCounter--; 49 | } 50 | 51 | systimer_1ms_handler(); 52 | } 53 | 54 | /*! \brief initialise platform before main() 55 | */ 56 | __attribute__((constructor(101))) 57 | void platform_init(void) 58 | { 59 | SystemCoreClockUpdate(); 60 | 61 | /* Generate interrupt each 1 ms */ 62 | SysTick_Config(SystemCoreClock / 1000); 63 | 64 | #if defined(RTE_Compiler_EventRecorder) && defined(RTE_Compiler_IO_STDOUT_EVR) 65 | EventRecorderInitialize(0,1); 66 | #else 67 | uart_config(25000000ul); 68 | #endif 69 | } 70 | 71 | 72 | -------------------------------------------------------------------------------- /gen_pack.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Version: 2.7 3 | # Date: 2023-05-22 4 | # This bash script generates a CMSIS Software Pack: 5 | # 6 | 7 | set -o pipefail 8 | 9 | # Set version of gen pack library 10 | # For available versions see https://github.com/Open-CMSIS-Pack/gen-pack/tags. 11 | # Use the tag name without the prefix "v", e.g., 0.7.0 12 | REQUIRED_GEN_PACK_LIB="0.8.4" 13 | 14 | # Set default command line arguments 15 | DEFAULT_ARGS=(-c "v") 16 | 17 | # Pack warehouse directory - destination 18 | # Default: ./output 19 | # 20 | # PACK_OUTPUT=./output 21 | 22 | # Temporary pack build directory, 23 | # Default: ./build 24 | # 25 | # PACK_BUILD=./build 26 | 27 | # Specify directory names to be added to pack base directory 28 | # An empty list defaults to all folders next to this script. 29 | # Default: empty (all folders) 30 | # 31 | PACK_DIRS=" 32 | benchmark 33 | documents 34 | os 35 | template 36 | " 37 | 38 | # Specify file names to be added to pack base directory 39 | # Default: empty 40 | # 41 | PACK_BASE_FILES=" 42 | LICENSE 43 | perf_counter.c 44 | perf_counter.h 45 | perfc_port_default.c 46 | perfc_port_default.h 47 | perfc_port_pmu.c 48 | perfc_port_pmu.h 49 | README.md 50 | systick_wrapper_gcc.S 51 | systick_wrapper_gnu.s 52 | systick_wrapper_ual.s 53 | " 54 | 55 | # Specify file names to be deleted from pack build directory 56 | # Default: empty 57 | # 58 | # PACK_DELETE_FILES=" 59 | # " 60 | 61 | # Specify patches to be applied 62 | # Default: empty 63 | # 64 | # PACK_PATCH_FILES=" 65 | # 66 | # " 67 | 68 | # Specify addition argument to packchk 69 | # Default: empty 70 | # 71 | # PACKCHK_ARGS=() 72 | 73 | # Specify additional dependencies for packchk 74 | # Default: empty 75 | # 76 | # PACKCHK_DEPS=" 77 | # 78 | # " 79 | 80 | # Optional: restrict fallback modes for changelog generation 81 | # Default: full 82 | # Values: 83 | # - full Tag annotations, release descriptions, or commit messages (in order) 84 | # - release Tag annotations, or release descriptions (in order) 85 | # - tag Tag annotations only 86 | # 87 | # PACK_CHANGELOG_MODE="" 88 | 89 | # 90 | # custom pre-processing steps 91 | # 92 | # usage: preprocess 93 | # The build folder 94 | # 95 | function preprocess() { 96 | # add custom steps here to be executed 97 | # before populating the pack build folder 98 | return 0 99 | } 100 | 101 | # 102 | # custom post-processing steps 103 | # 104 | # usage: postprocess 105 | # The build folder 106 | # 107 | function postprocess() { 108 | # add custom steps here to be executed 109 | # after populating the pack build folder 110 | # but before archiving the pack into output folder 111 | return 0 112 | } 113 | 114 | ############ DO NOT EDIT BELOW ########### 115 | 116 | function install_lib() { 117 | local URL="https://github.com/Open-CMSIS-Pack/gen-pack/archive/refs/tags/v$1.tar.gz" 118 | local STATUS=$(curl -sLI "${URL}" | grep "^HTTP" | tail -n 1 | cut -d' ' -f2 || echo "$((600+$?))") 119 | if [[ $STATUS -ge 400 ]]; then 120 | echo "Wrong/unavailable gen-pack lib version '$1'!" >&2 121 | echo "Check REQUIRED_GEN_PACK_LIB variable." >&2 122 | echo "For available versions see https://github.com/Open-CMSIS-Pack/gen-pack/tags." >&2 123 | exit 1 124 | fi 125 | echo "Downloading gen-pack lib version '$1' to '$2' ..." 126 | mkdir -p "$2" 127 | curl -L "${URL}" -s | tar -xzf - --strip-components 1 -C "$2" || exit 1 128 | } 129 | 130 | function load_lib() { 131 | if [[ -d ${GEN_PACK_LIB} ]]; then 132 | . "${GEN_PACK_LIB}/gen-pack" 133 | return 0 134 | fi 135 | local GLOBAL_LIB="/usr/local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}" 136 | local USER_LIB="${HOME}/.local/share/gen-pack/${REQUIRED_GEN_PACK_LIB}" 137 | if [[ ! -d "${GLOBAL_LIB}" && ! -d "${USER_LIB}" ]]; then 138 | echo "Required gen_pack lib not found!" >&2 139 | install_lib "${REQUIRED_GEN_PACK_LIB}" "${USER_LIB}" 140 | fi 141 | 142 | if [[ -d "${GLOBAL_LIB}" ]]; then 143 | . "${GLOBAL_LIB}/gen-pack" 144 | elif [[ -d "${USER_LIB}" ]]; then 145 | . "${USER_LIB}/gen-pack" 146 | else 147 | echo "Required gen-pack lib is not installed!" >&2 148 | exit 1 149 | fi 150 | } 151 | 152 | load_lib 153 | gen_pack "${DEFAULT_ARGS[@]}" "$@" 154 | 155 | exit 0 -------------------------------------------------------------------------------- /os/perf_os_patch_rt_thread.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright 2022 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) * 3 | * * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); * 5 | * you may not use this file except in compliance with the License. * 6 | * You may obtain a copy of the License at * 7 | * * 8 | * http://www.apache.org/licenses/LICENSE-2.0 * 9 | * * 10 | * Unless required by applicable law or agreed to in writing, software * 11 | * distributed under the License is distributed on an "AS IS" BASIS, * 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 13 | * See the License for the specific language governing permissions and * 14 | * limitations under the License. * 15 | * * 16 | ****************************************************************************/ 17 | 18 | 19 | /*============================ INCLUDES ======================================*/ 20 | 21 | 22 | #include 23 | #include "perf_counter.h" 24 | #include "cmsis_compiler.h" 25 | 26 | /*============================ MACROS ========================================*/ 27 | 28 | #undef __WRAP_FUNC 29 | #undef WRAP_FUNC 30 | #if defined(__IS_COMPILER_ARM_COMPILER__) && __IS_COMPILER_ARM_COMPILER__ 31 | 32 | # define __WRAP_FUNC(__NAME) $Sub$$##__NAME 33 | # define __ORIG_FUNC(__NAME) $Super$$##__NAME 34 | 35 | #elif (defined(__IS_COMPILER_LLVM__) && __IS_COMPILER_LLVM__) \ 36 | || (defined(__IS_COMPILER_GCC__) && __IS_COMPILER_GCC__) 37 | 38 | # define __WRAP_FUNC(__NAME) __wrap_##__NAME 39 | # define __ORIG_FUNC(__NAME) __real_##__NAME 40 | 41 | #endif 42 | #define WRAP_FUNC(__NAME) __WRAP_FUNC(__NAME) 43 | #define ORIG_FUNC(__NAME) __ORIG_FUNC(__NAME) 44 | 45 | struct __task_cycle_info_t { 46 | task_cycle_info_t tInfo; 47 | int64_t lLastTimeStamp; 48 | task_cycle_info_agent_t tList; 49 | uint32_t wMagicWord; 50 | } ; 51 | 52 | #ifndef RT_USING_HOOK 53 | #error "In order to use perf_counter:RT-Thread-Patch, please define RT_USING_HOOK \ 54 | in rtconfig.h. If you don't want to use this patch, please un-select it in RTE." 55 | #endif 56 | 57 | 58 | /*============================ TYPES =========================================*/ 59 | /*============================ GLOBAL VARIABLES ==============================*/ 60 | /*============================ LOCAL VARIABLES ===============================*/ 61 | /*============================ PROTOTYPES ====================================*/ 62 | extern void __on_context_switch_in(uint32_t *pwStack); 63 | extern void __on_context_switch_out(uint32_t *pwStack); 64 | extern struct rt_thread *rt_current_thread; 65 | /*============================ IMPLEMENTATION ================================*/ 66 | 67 | void __rt_thread_scheduler_hook(struct rt_thread *from, struct rt_thread *to) 68 | { 69 | if (NULL != from) { 70 | __on_context_switch_out(from->stack_addr); 71 | } 72 | 73 | __on_context_switch_in(to->stack_addr); 74 | } 75 | 76 | task_cycle_info_t * get_rtos_task_cycle_info(void) 77 | { 78 | return &(((struct __task_cycle_info_t *)rt_current_thread->stack_addr)->tInfo); 79 | } 80 | 81 | void __perf_os_patch_init(void) 82 | { 83 | #if defined(RTTHREAD_VERSION) && (RTTHREAD_VERSION >= (4 * 10000)) 84 | rt_tick_sethook(user_code_insert_to_systick_handler); 85 | #endif 86 | 87 | #if !defined(PKG_USING_PERF_COUNTER) || (defined(PKG_PERF_COUNTER_USING_THREAD_STATISTIC)) 88 | rt_scheduler_sethook(__rt_thread_scheduler_hook); 89 | #endif 90 | } 91 | 92 | #ifdef PKG_USING_PERF_COUNTER 93 | 94 | #if defined(RTTHREAD_VERSION) && (RTTHREAD_VERSION >= (4 * 10000)) 95 | void __ensure_systick_wrapper(void) 96 | { 97 | } 98 | #endif 99 | 100 | #define DBG_TAG "perf_counter" 101 | #define DBG_LVL DBG_INFO 102 | #include 103 | 104 | static int _perf_counter_init(void) 105 | { 106 | extern uint32_t SystemCoreClock; 107 | init_cycle_counter(true); 108 | LOG_I("perf_counter init, SystemCoreClock:%d", SystemCoreClock); 109 | return 0; 110 | } 111 | INIT_PREV_EXPORT(_perf_counter_init); 112 | #endif /* PKG_USING_PERF_COUNTER */ 113 | -------------------------------------------------------------------------------- /os/perf_os_patch_rtx5.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright 2022 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) * 3 | * * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); * 5 | * you may not use this file except in compliance with the License. * 6 | * You may obtain a copy of the License at * 7 | * * 8 | * http://www.apache.org/licenses/LICENSE-2.0 * 9 | * * 10 | * Unless required by applicable law or agreed to in writing, software * 11 | * distributed under the License is distributed on an "AS IS" BASIS, * 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 13 | * See the License for the specific language governing permissions and * 14 | * limitations under the License. * 15 | * * 16 | ****************************************************************************/ 17 | 18 | 19 | /*============================ INCLUDES ======================================*/ 20 | 21 | 22 | #include "rtx_os.h" 23 | #include "perf_counter.h" 24 | #include "cmsis_compiler.h" 25 | #include "rtx_evr.h" // RTX Event Recorder definitions 26 | 27 | /*============================ MACROS ========================================*/ 28 | 29 | #undef __WRAP_FUNC 30 | #undef WRAP_FUNC 31 | #if defined(__IS_COMPILER_ARM_COMPILER__) && __IS_COMPILER_ARM_COMPILER__ 32 | 33 | # define __WRAP_FUNC(__NAME) $Sub$$##__NAME 34 | # define __ORIG_FUNC(__NAME) $Super$$##__NAME 35 | 36 | #elif (defined(__IS_COMPILER_LLVM__) && __IS_COMPILER_LLVM__) \ 37 | || (defined(__IS_COMPILER_GCC__) && __IS_COMPILER_GCC__) 38 | 39 | # define __WRAP_FUNC(__NAME) __wrap_##__NAME 40 | # define __ORIG_FUNC(__NAME) __real_##__NAME 41 | 42 | #endif 43 | #define WRAP_FUNC(__NAME) __WRAP_FUNC(__NAME) 44 | #define ORIG_FUNC(__NAME) __ORIG_FUNC(__NAME) 45 | 46 | struct __task_cycle_info_t { 47 | task_cycle_info_t tInfo; 48 | int64_t lLastTimeStamp; 49 | task_cycle_info_agent_t tList; 50 | uint32_t wMagicWord; 51 | } ; 52 | 53 | 54 | /*============================ TYPES =========================================*/ 55 | /*============================ GLOBAL VARIABLES ==============================*/ 56 | /*============================ LOCAL VARIABLES ===============================*/ 57 | /*============================ PROTOTYPES ====================================*/ 58 | extern void __on_context_switch_in(uint32_t *pwStack); 59 | extern void __on_context_switch_out(uint32_t *pwStack); 60 | 61 | /*============================ IMPLEMENTATION ================================*/ 62 | 63 | 64 | /*! \brief wrapper function for rtos context switching */ 65 | void __on_context_switch (osRtxThread_t *thread) 66 | { 67 | if (NULL != osRtxInfo.thread.run.curr) { 68 | __on_context_switch_out(osRtxInfo.thread.run.curr->stack_mem); 69 | } 70 | 71 | __on_context_switch_in(thread->stack_mem); 72 | } 73 | 74 | __attribute__((used)) 75 | void EvrRtxThreadSwitched (osThreadId_t thread_id) 76 | { 77 | __on_context_switch((osRtxThread_t *)thread_id); 78 | 79 | #if defined(RTE_Compiler_EventRecorder) || defined(RTE_CMSIS_View_EventRecorder) 80 | # define EvtRtxThreadSwitched \ 81 | EventID(EventLevelOp, EvtRtxThreadNo, 0x19U) 82 | 83 | (void)EventRecord2(EvtRtxThreadSwitched, (uint32_t)thread_id, 0U); 84 | #else 85 | (void)thread_id; 86 | #endif 87 | } 88 | 89 | 90 | task_cycle_info_t * get_rtos_task_cycle_info(void) 91 | { 92 | osRtxThread_t *curr = osRtxInfo.thread.run.curr; 93 | if (NULL == curr) { 94 | return NULL; 95 | } 96 | 97 | return &(((struct __task_cycle_info_t *)curr->stack_mem)->tInfo); 98 | } 99 | 100 | -------------------------------------------------------------------------------- /os/perf_os_patch_threadx.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright 2022 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) * 3 | * * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); * 5 | * you may not use this file except in compliance with the License. * 6 | * You may obtain a copy of the License at * 7 | * * 8 | * http://www.apache.org/licenses/LICENSE-2.0 * 9 | * * 10 | * Unless required by applicable law or agreed to in writing, software * 11 | * distributed under the License is distributed on an "AS IS" BASIS, * 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 13 | * See the License for the specific language governing permissions and * 14 | * limitations under the License. * 15 | * * 16 | ****************************************************************************/ 17 | 18 | 19 | /*============================ INCLUDES ======================================*/ 20 | 21 | #include "tx_api.h" 22 | #include "tx_thread.h" 23 | 24 | #include "perf_counter.h" 25 | #include "cmsis_compiler.h" 26 | 27 | /*============================ MACROS ========================================*/ 28 | 29 | #undef __WRAP_FUNC 30 | #undef WRAP_FUNC 31 | #if defined(__IS_COMPILER_ARM_COMPILER__) && __IS_COMPILER_ARM_COMPILER__ 32 | 33 | # define __WRAP_FUNC(__NAME) $Sub$$##__NAME 34 | # define __ORIG_FUNC(__NAME) $Super$$##__NAME 35 | 36 | #elif (defined(__IS_COMPILER_LLVM__) && __IS_COMPILER_LLVM__) \ 37 | || (defined(__IS_COMPILER_GCC__) && __IS_COMPILER_GCC__) 38 | 39 | # define __WRAP_FUNC(__NAME) __wrap_##__NAME 40 | # define __ORIG_FUNC(__NAME) __real_##__NAME 41 | 42 | #endif 43 | #define WRAP_FUNC(__NAME) __WRAP_FUNC(__NAME) 44 | #define ORIG_FUNC(__NAME) __ORIG_FUNC(__NAME) 45 | 46 | 47 | #if defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) && defined(TX_EXECUTION_PROFILE_ENABLE) 48 | #error In order to use perf_counter:ThreadX-Patch, please define \ 49 | TX_ENABLE_EXECUTION_CHANGE_NOTIFY or TX_EXECUTION_PROFILE_ENABLE \ 50 | in the project configuration, according to the version of thread.\ 51 | If you don't want to use this patch, please un-select it in RTE\ 52 | or remove this patch from the compilation. 53 | #endif 54 | 55 | 56 | /*============================ TYPES =========================================*/ 57 | struct __task_cycle_info_t { 58 | task_cycle_info_t tInfo; 59 | int64_t lLastTimeStamp; 60 | task_cycle_info_agent_t tList; 61 | uint32_t wMagicWord; 62 | } ; 63 | 64 | 65 | /*============================ GLOBAL VARIABLES ==============================*/ 66 | /*============================ LOCAL VARIABLES ===============================*/ 67 | /*============================ PROTOTYPES ====================================*/ 68 | extern void __on_context_switch_in(uint32_t *pwStack); 69 | extern void __on_context_switch_out(uint32_t *pwStack); 70 | 71 | /*============================ IMPLEMENTATION ================================*/ 72 | 73 | #if defined(TX_EXECUTION_PROFILE_ENABLE) 74 | void WRAP_FUNC(_tx_execution_thread_enter)(void) 75 | #else 76 | void _tx_execution_thread_enter (void) 77 | #endif 78 | { 79 | TX_THREAD * ptThread = NULL; 80 | TX_THREAD_GET_CURRENT(ptThread); 81 | 82 | __on_context_switch_in(ptThread->tx_thread_stack_start); 83 | 84 | #if defined(TX_EXECUTION_PROFILE_ENABLE) 85 | extern void ORIG_FUNC(_tx_execution_thread_enter)(void); 86 | 87 | ORIG_FUNC(_tx_execution_thread_enter)(); 88 | #endif 89 | } 90 | 91 | #if defined(TX_EXECUTION_PROFILE_ENABLE) 92 | void WRAP_FUNC(_tx_execution_thread_exit)(void) 93 | #else 94 | void _tx_execution_thread_exit(void) 95 | #endif 96 | { 97 | TX_THREAD * ptThread = NULL; 98 | TX_THREAD_GET_CURRENT(ptThread); 99 | 100 | if (NULL != ptThread) { 101 | __on_context_switch_out(ptThread->tx_thread_stack_start); 102 | } 103 | #if defined(TX_EXECUTION_PROFILE_ENABLE) 104 | extern void ORIG_FUNC(_tx_execution_thread_exit)(void); 105 | 106 | ORIG_FUNC(_tx_execution_thread_exit)(); 107 | #endif 108 | } 109 | 110 | #if !defined(TX_EXECUTION_PROFILE_ENABLE) 111 | void _tx_execution_isr_exit(void) 112 | { 113 | 114 | } 115 | 116 | void _tx_execution_isr_enter(void) 117 | { 118 | 119 | } 120 | #endif 121 | 122 | task_cycle_info_t * get_rtos_task_cycle_info(void) 123 | { 124 | TX_THREAD * ptThread = NULL; 125 | TX_THREAD_GET_CURRENT(ptThread); 126 | 127 | return &(((struct __task_cycle_info_t *)ptThread->tx_thread_stack_start)->tInfo); 128 | } 129 | -------------------------------------------------------------------------------- /perfc_port_default.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright 2024 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) * 3 | * * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); * 5 | * you may not use this file except in compliance with the License. * 6 | * You may obtain a copy of the License at * 7 | * * 8 | * http://www.apache.org/licenses/LICENSE-2.0 * 9 | * * 10 | * Unless required by applicable law or agreed to in writing, software * 11 | * distributed under the License is distributed on an "AS IS" BASIS, * 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 13 | * See the License for the specific language governing permissions and * 14 | * limitations under the License. * 15 | * * 16 | ****************************************************************************/ 17 | 18 | /*============================ INCLUDES ======================================*/ 19 | 20 | #ifndef __PERFC_CFG_DISABLE_DEFAULT_SYSTICK_PORTING__ 21 | # define __PERFC_CFG_DISABLE_DEFAULT_SYSTICK_PORTING__ 0 22 | #endif 23 | 24 | #if !__PERFC_CFG_DISABLE_DEFAULT_SYSTICK_PORTING__ 25 | 26 | #include "cmsis_compiler.h" 27 | 28 | /*============================ MACROS ========================================*/ 29 | /*============================ MACROFIED FUNCTIONS ===========================*/ 30 | 31 | #ifndef __perfc_sync_barrier__ 32 | # define __perfc_sync_barrier__(...) do {__DSB();__ISB();} while(0) 33 | #endif 34 | 35 | /*============================ TYPES =========================================*/ 36 | typedef uint32_t perfc_global_interrupt_status_t; 37 | 38 | /*============================ GLOBAL VARIABLES ==============================*/ 39 | /*============================ LOCAL VARIABLES ===============================*/ 40 | /*============================ PROTOTYPES ====================================*/ 41 | /*============================ IMPLEMENTATION ================================*/ 42 | 43 | __STATIC_INLINE 44 | perfc_global_interrupt_status_t perfc_port_disable_global_interrupt(void) 45 | { 46 | perfc_global_interrupt_status_t tStatus = __get_PRIMASK(); 47 | __disable_irq(); 48 | 49 | return tStatus; 50 | } 51 | 52 | __STATIC_INLINE 53 | void perfc_port_resume_global_interrupt(perfc_global_interrupt_status_t tStatus) 54 | { 55 | __set_PRIMASK(tStatus); 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /perfc_port_pmu.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright 2024 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) * 3 | * * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); * 5 | * you may not use this file except in compliance with the License. * 6 | * You may obtain a copy of the License at * 7 | * * 8 | * http://www.apache.org/licenses/LICENSE-2.0 * 9 | * * 10 | * Unless required by applicable law or agreed to in writing, software * 11 | * distributed under the License is distributed on an "AS IS" BASIS, * 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 13 | * See the License for the specific language governing permissions and * 14 | * limitations under the License. * 15 | * * 16 | ****************************************************************************/ 17 | 18 | /*============================ INCLUDES ======================================*/ 19 | 20 | #if __PERFC_USE_PMU_PORTING__ 21 | 22 | #include "cmsis_compiler.h" 23 | 24 | /*============================ MACROS ========================================*/ 25 | /*============================ MACROFIED FUNCTIONS ===========================*/ 26 | #ifndef __perfc_sync_barrier__ 27 | # define __perfc_sync_barrier__(...) do {__DSB();__ISB();} while(0) 28 | #endif 29 | 30 | 31 | #define __cpu_perf__(__str, ...) \ 32 | using( \ 33 | struct { \ 34 | uint64_t dwNoInstr; \ 35 | uint64_t dwNoMemAccess; \ 36 | uint64_t dwNoL1DCacheRefill; \ 37 | int64_t lCycles; \ 38 | uint32_t wInstrCalib; \ 39 | uint32_t wMemAccessCalib; \ 40 | float fCPI; \ 41 | float fDCacheMissRate; \ 42 | } __PERF_INFO__ = {0}, \ 43 | ({ \ 44 | __PERF_INFO__.dwNoInstr = perfc_pmu_get_instruction_count(); \ 45 | __PERF_INFO__.dwNoMemAccess = perfc_pmu_get_memory_access_count(); \ 46 | __PERF_INFO__.wInstrCalib = perfc_pmu_get_instruction_count() \ 47 | - __PERF_INFO__.dwNoInstr; \ 48 | __PERF_INFO__.wMemAccessCalib = perfc_pmu_get_memory_access_count() \ 49 | - __PERF_INFO__.dwNoMemAccess; \ 50 | __PERF_INFO__.dwNoL1DCacheRefill \ 51 | = perfc_pmu_get_L1_dcache_refill_count(); \ 52 | __PERF_INFO__.dwNoInstr = perfc_pmu_get_instruction_count(); \ 53 | __PERF_INFO__.dwNoMemAccess = perfc_pmu_get_memory_access_count(); \ 54 | }), \ 55 | ({ \ 56 | __PERF_INFO__.dwNoInstr = perfc_pmu_get_instruction_count() \ 57 | - __PERF_INFO__.dwNoInstr \ 58 | - __PERF_INFO__.wInstrCalib; \ 59 | __PERF_INFO__.dwNoMemAccess = perfc_pmu_get_memory_access_count() \ 60 | - __PERF_INFO__.dwNoMemAccess \ 61 | - __PERF_INFO__.wMemAccessCalib; \ 62 | __PERF_INFO__.dwNoL1DCacheRefill \ 63 | = perfc_pmu_get_L1_dcache_refill_count() \ 64 | - __PERF_INFO__.dwNoL1DCacheRefill; \ 65 | \ 66 | __PERF_INFO__.fDCacheMissRate \ 67 | = (float)( (double)__PERF_INFO__.dwNoL1DCacheRefill \ 68 | / (double)__PERF_INFO__.dwNoMemAccess) \ 69 | * 100.0f; \ 70 | \ 71 | __PERF_INFO__.fCPI = (float)( (double)__PERF_INFO__.lCycles \ 72 | / (double)__PERF_INFO__.dwNoInstr); \ 73 | if (__PLOOC_VA_NUM_ARGS(__VA_ARGS__) == 0) { \ 74 | __perf_counter_printf__( "\r\n" \ 75 | "[Report for " __str "]\r\n" \ 76 | "-----------------------------------------\r\n" \ 77 | "Instruction executed: %lld\r\n" \ 78 | "Cycle Used: %lld\r\n" \ 79 | "Cycles per Instructions: %3.3f \r\n\r\n" \ 80 | "Memory Access Count: %lld\r\n" \ 81 | "L1 DCache Refill Count: %lld\r\n" \ 82 | "L1 DCache Miss Rate: %3.4f %% \r\n" \ 83 | , \ 84 | __PERF_INFO__.dwNoInstr, \ 85 | __PERF_INFO__.lCycles, \ 86 | (double)__PERF_INFO__.fCPI, \ 87 | __PERF_INFO__.dwNoMemAccess, \ 88 | __PERF_INFO__.dwNoL1DCacheRefill, \ 89 | (double)__PERF_INFO__.fDCacheMissRate \ 90 | ); \ 91 | } else { \ 92 | __VA_ARGS__ \ 93 | } \ 94 | })) \ 95 | __cycleof__("", { __PERF_INFO__.lCycles = __cycle_count__; }) 96 | 97 | 98 | /*============================ TYPES =========================================*/ 99 | typedef uint32_t perfc_global_interrupt_status_t; 100 | 101 | /*============================ GLOBAL VARIABLES ==============================*/ 102 | /*============================ LOCAL VARIABLES ===============================*/ 103 | /*============================ PROTOTYPES ====================================*/ 104 | extern 105 | void perfc_port_pmu_insert_to_debug_monitor_handler(void); 106 | 107 | extern 108 | uint64_t perfc_pmu_get_instruction_count(void); 109 | 110 | extern 111 | uint64_t perfc_pmu_get_memory_access_count(void); 112 | 113 | extern 114 | uint64_t perfc_pmu_get_L1_dcache_refill_count(void); 115 | 116 | /*============================ IMPLEMENTATION ================================*/ 117 | 118 | __STATIC_INLINE 119 | perfc_global_interrupt_status_t perfc_port_disable_global_interrupt(void) 120 | { 121 | perfc_global_interrupt_status_t tStatus = __get_PRIMASK(); 122 | __disable_irq(); 123 | 124 | return tStatus; 125 | } 126 | 127 | __STATIC_INLINE 128 | void perfc_port_resume_global_interrupt(perfc_global_interrupt_status_t tStatus) 129 | { 130 | __set_PRIMASK(tStatus); 131 | } 132 | 133 | 134 | 135 | 136 | #endif -------------------------------------------------------------------------------- /systick_wrapper_gcc.S: -------------------------------------------------------------------------------- 1 | ;/**************************************************************************** 2 | ;* Copyright 2024 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) * 3 | ;* * 4 | ;* Licensed under the Apache License, Version 2.0 (the "License"); * 5 | ;* you may not use this file except in compliance with the License. * 6 | ;* You may obtain a copy of the License at * 7 | ;* * 8 | ;* http://www.apache.org/licenses/LICENSE-2.0 * 9 | ;* * 10 | ;* Unless required by applicable law or agreed to in writing, software * 11 | ;* distributed under the License is distributed on an "AS IS" BASIS, * 12 | ;* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 13 | ;* See the License for the specific language governing permissions and * 14 | ;* limitations under the License. * 15 | ;* * 16 | ;****************************************************************************/ 17 | 18 | .syntax unified 19 | .arch armv6-m 20 | 21 | .text 22 | .thumb 23 | .thumb_func 24 | .align 2 25 | .globl __wrap_SysTick_Handler 26 | .type __wrap_SysTick_Handler, %function 27 | 28 | __wrap_SysTick_Handler: 29 | push {r4, r5} 30 | push {r4, lr} 31 | ldr R0, =perfc_port_insert_to_system_timer_insert_ovf_handler 32 | blx R0 33 | pop {r4, r5} 34 | mov lr, r5 35 | pop {r4, r5} 36 | ldr R0, =__real_SysTick_Handler 37 | bx R0 38 | 39 | 40 | .globl __ensure_systick_wrapper 41 | .type __ensure_systick_wrapper, %function 42 | 43 | __ensure_systick_wrapper: 44 | bx lr 45 | -------------------------------------------------------------------------------- /systick_wrapper_gnu.s: -------------------------------------------------------------------------------- 1 | ;/**************************************************************************** 2 | ;* Copyright 2024 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) * 3 | ;* * 4 | ;* Licensed under the Apache License, Version 2.0 (the "License"); * 5 | ;* you may not use this file except in compliance with the License. * 6 | ;* You may obtain a copy of the License at * 7 | ;* * 8 | ;* http://www.apache.org/licenses/LICENSE-2.0 * 9 | ;* * 10 | ;* Unless required by applicable law or agreed to in writing, software * 11 | ;* distributed under the License is distributed on an "AS IS" BASIS, * 12 | ;* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 13 | ;* See the License for the specific language governing permissions and * 14 | ;* limitations under the License. * 15 | ;* * 16 | ;****************************************************************************/ 17 | 18 | .syntax unified 19 | .arch armv6-m 20 | 21 | .eabi_attribute Tag_ABI_align_preserved, 1 22 | .text 23 | .thumb 24 | .thumb_func 25 | .align 2 26 | .globl $Sub$$SysTick_Handler 27 | .type $Sub$$SysTick_Handler, %function 28 | 29 | $Sub$$SysTick_Handler: 30 | push {r4, r5} 31 | push {r4, lr} 32 | ldr R0, =perfc_port_insert_to_system_timer_insert_ovf_handler 33 | blx R0 34 | pop {r4, r5} 35 | mov lr, r5 36 | pop {r4, r5} 37 | ldr R0, =$Super$$SysTick_Handler 38 | bx R0 39 | 40 | .globl __ensure_systick_wrapper 41 | .type __ensure_systick_wrapper, %function 42 | 43 | __ensure_systick_wrapper: 44 | bx lr -------------------------------------------------------------------------------- /systick_wrapper_ual.s: -------------------------------------------------------------------------------- 1 | ;/**************************************************************************** 2 | ;* Copyright 2022 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) * 3 | ;* * 4 | ;* Licensed under the Apache License, Version 2.0 (the "License"); * 5 | ;* you may not use this file except in compliance with the License. * 6 | ;* You may obtain a copy of the License at * 7 | ;* * 8 | ;* http://www.apache.org/licenses/LICENSE-2.0 * 9 | ;* * 10 | ;* Unless required by applicable law or agreed to in writing, software * 11 | ;* distributed under the License is distributed on an "AS IS" BASIS, * 12 | ;* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 13 | ;* See the License for the specific language governing permissions and * 14 | ;* limitations under the License. * 15 | ;* * 16 | ;****************************************************************************/ 17 | 18 | 19 | PRESERVE8 20 | THUMB 21 | AREA |.text|, CODE, READONLY 22 | 23 | |$Sub$$SysTick_Handler| PROC 24 | EXPORT |$Sub$$SysTick_Handler| 25 | IMPORT perfc_port_insert_to_system_timer_insert_ovf_handler 26 | IMPORT |$Super$$SysTick_Handler| 27 | push {r4, r5} 28 | push {r4, lr} 29 | LDR R0, =perfc_port_insert_to_system_timer_insert_ovf_handler 30 | BLX R0 31 | pop {r4, r5} 32 | mov lr, r5 33 | pop {r4, r5} 34 | LDR R0, =|$Super$$SysTick_Handler| 35 | BX R0 36 | ENDP 37 | 38 | ALIGN 39 | AREA |.text|, CODE, READONLY 40 | 41 | __ensure_systick_wrapper PROC 42 | EXPORT __ensure_systick_wrapper 43 | NOP 44 | BX LR 45 | ENDP 46 | 47 | END -------------------------------------------------------------------------------- /template/perfc_port_user.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright 2024 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) * 3 | * * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); * 5 | * you may not use this file except in compliance with the License. * 6 | * You may obtain a copy of the License at * 7 | * * 8 | * http://www.apache.org/licenses/LICENSE-2.0 * 9 | * * 10 | * Unless required by applicable law or agreed to in writing, software * 11 | * distributed under the License is distributed on an "AS IS" BASIS, * 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 13 | * See the License for the specific language governing permissions and * 14 | * limitations under the License. * 15 | * * 16 | ****************************************************************************/ 17 | 18 | /*============================ INCLUDES ======================================*/ 19 | #undef __PERF_COUNT_PLATFORM_SPECIFIC_HEADER__ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #define __IMPLEMENT_PERF_COUNTER 26 | #include "perf_counter.h" 27 | 28 | #if defined(__IS_COMPILER_GCC__) 29 | # pragma GCC diagnostic ignored "-Wattributes" 30 | #endif 31 | 32 | #if defined(__clang__) 33 | # pragma clang diagnostic ignored "-Wunknown-warning-option" 34 | # pragma clang diagnostic ignored "-Wreserved-identifier" 35 | # pragma clang diagnostic ignored "-Wconditional-uninitialized" 36 | # pragma clang diagnostic ignored "-Wcast-align" 37 | # pragma clang diagnostic ignored "-Wmissing-prototypes" 38 | #endif 39 | 40 | 41 | /*============================ MACROS ========================================*/ 42 | /*============================ MACROFIED FUNCTIONS ===========================*/ 43 | /*============================ TYPES =========================================*/ 44 | /*============================ GLOBAL VARIABLES ==============================*/ 45 | /*============================ LOCAL VARIABLES ===============================*/ 46 | /*============================ PROTOTYPES ====================================*/ 47 | /* low level interface for porting */ 48 | extern 49 | uint32_t perfc_port_get_system_timer_freq(void); 50 | extern 51 | int64_t perfc_port_get_system_timer_top(void); 52 | extern 53 | bool perfc_port_is_system_timer_ovf_pending(void); 54 | extern 55 | bool perfc_port_init_system_timer(bool bTimerOccupied); 56 | extern 57 | int64_t perfc_port_get_system_timer_elapsed(void); 58 | extern 59 | void perfc_port_clear_system_timer_ovf_pending(void); 60 | extern 61 | void perfc_port_stop_system_timer_counting(void); 62 | extern 63 | void perfc_port_clear_system_timer_counter(void); 64 | 65 | /*============================ IMPLEMENTATION ================================*/ 66 | /*============================ INCLUDES ======================================*/ 67 | 68 | #if __PERFC_USE_USER_CUSTOM_PORTING__ 69 | 70 | bool perfc_port_init_system_timer(bool bIsTimeOccupied) 71 | { 72 | bool bResult = true; 73 | do { 74 | if (bIsTimeOccupied) { 75 | break; 76 | } 77 | 78 | __IRQ_SAFE { 79 | /* Configure the system timer count with the longest possible period 80 | * clear counter 81 | * Clear overflow pending flag 82 | * Enable interrupt if required 83 | * start counting 84 | */ 85 | } 86 | } while(0); 87 | 88 | return true; 89 | } 90 | 91 | uint32_t perfc_port_get_system_timer_freq(void) 92 | { 93 | /* return the system timer frequency */ 94 | return 0; 95 | } 96 | 97 | bool perfc_port_is_system_timer_ovf_pending(void) 98 | { 99 | /* whether the system timer overflow is pending */ 100 | return false; 101 | } 102 | 103 | int64_t perfc_port_get_system_timer_top(void) 104 | { 105 | /* the top value of the counting */ 106 | return 0; 107 | } 108 | 109 | int64_t perfc_port_get_system_timer_elapsed(void) 110 | { 111 | /* the elapsed count number since last overflow */ 112 | return 0; 113 | } 114 | 115 | void perfc_port_clear_system_timer_ovf_pending(void) 116 | { 117 | /* clear the overflow pending flag */ 118 | } 119 | 120 | void perfc_port_stop_system_timer_counting(void) 121 | { 122 | /* stop the system timer */ 123 | } 124 | 125 | void perfc_port_clear_system_timer_counter(void) 126 | { 127 | /* clear the system timer counter */ 128 | } 129 | 130 | #endif 131 | 132 | 133 | -------------------------------------------------------------------------------- /template/perfc_port_user.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright 2024 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) * 3 | * * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); * 5 | * you may not use this file except in compliance with the License. * 6 | * You may obtain a copy of the License at * 7 | * * 8 | * http://www.apache.org/licenses/LICENSE-2.0 * 9 | * * 10 | * Unless required by applicable law or agreed to in writing, software * 11 | * distributed under the License is distributed on an "AS IS" BASIS, * 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 13 | * See the License for the specific language governing permissions and * 14 | * limitations under the License. * 15 | * * 16 | ****************************************************************************/ 17 | 18 | /*============================ INCLUDES ======================================*/ 19 | 20 | #if __PERFC_USE_USER_CUSTOM_PORTING__ 21 | 22 | /*============================ MACROS ========================================*/ 23 | /*============================ MACROFIED FUNCTIONS ===========================*/ 24 | /*============================ TYPES =========================================*/ 25 | typedef uint32_t perfc_global_interrupt_status_t; 26 | 27 | /*============================ GLOBAL VARIABLES ==============================*/ 28 | /*============================ LOCAL VARIABLES ===============================*/ 29 | /*============================ PROTOTYPES ====================================*/ 30 | /*============================ IMPLEMENTATION ================================*/ 31 | 32 | static 33 | inline 34 | perfc_global_interrupt_status_t perfc_port_disable_global_interrupt(void) 35 | { 36 | perfc_global_interrupt_status_t tStatus; 37 | 38 | /* get global interrupt status */ 39 | /* disable global interrupt */ 40 | /* return the status */ 41 | 42 | return tStatus; 43 | 44 | } 45 | 46 | static 47 | inline 48 | void perfc_port_resume_global_interrupt(perfc_global_interrupt_status_t tStatus) 49 | { 50 | /* resume the stored global interrupt status */ 51 | } 52 | 53 | #endif --------------------------------------------------------------------------------