diff --git a/GorgonMeducer.perf_counter.pdsc b/GorgonMeducer.perf_counter.pdsc index 57f77f4..a66cfaf 100644 --- a/GorgonMeducer.perf_counter.pdsc +++ b/GorgonMeducer.perf_counter.pdsc @@ -16,8 +16,9 @@ https://github.com/GorgonMeducer/perf_counter.git - + - Mitigate some clang warnings + - Minor update for RTOS support - Fix CONNECT macro cannot connect two parameters issue. @@ -156,7 +157,7 @@ --> - + A dedicated performance counter for Cortex-M systick. diff --git a/cmsis-pack/GorgonMeducer.perf_counter.1.9.4-alpha.pack b/cmsis-pack/GorgonMeducer.perf_counter.1.9.4-alpha.pack deleted file mode 100644 index abd390f..0000000 Binary files a/cmsis-pack/GorgonMeducer.perf_counter.1.9.4-alpha.pack and /dev/null differ diff --git a/cmsis-pack/GorgonMeducer.perf_counter.1.9.4.pack b/cmsis-pack/GorgonMeducer.perf_counter.1.9.4.pack new file mode 100644 index 0000000..7af4671 Binary files /dev/null and b/cmsis-pack/GorgonMeducer.perf_counter.1.9.4.pack differ diff --git a/cmsis-pack/GorgonMeducer.perf_counter.pdsc b/cmsis-pack/GorgonMeducer.perf_counter.pdsc index 57f77f4..a66cfaf 100644 --- a/cmsis-pack/GorgonMeducer.perf_counter.pdsc +++ b/cmsis-pack/GorgonMeducer.perf_counter.pdsc @@ -16,8 +16,9 @@ https://github.com/GorgonMeducer/perf_counter.git - + - Mitigate some clang warnings + - Minor update for RTOS support - Fix CONNECT macro cannot connect two parameters issue. @@ -156,7 +157,7 @@ --> - + A dedicated performance counter for Cortex-M systick. diff --git a/example/ArInp.bat b/example/ArInp.bat index 5b3dddb..43f22a8 100644 --- a/example/ArInp.bat +++ b/example/ArInp.bat @@ -1 +1 @@ -"C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2020-q4-major\bin\arm-none-eabi-ar" -M 1 0 - 1 + 0 7 @@ -292,7 +292,7 @@ 1 0 - 0 + 1 7 diff --git a/example/example.uvprojx b/example/example.uvprojx index 0bd5ecb..343b2e3 100644 --- a/example/example.uvprojx +++ b/example/example.uvprojx @@ -10,7 +10,7 @@ example_arm_compiler_6 0x4 ARM-ADS - 6170000::V6.17::.\Arm Compiler 6.17 + 6180000::V6.18::.\Arm Compiler 6.18 1 @@ -337,7 +337,7 @@ 0 -Wno-missing-prototypes -Wno-reserved-identifier -Wno-sign-conversion -Wno-c11-extensions -Wno-implicit-int-conversion - __PERF_CNT_USE_LONG_CLOCK__ + .. @@ -529,7 +529,7 @@ library 0x4 ARM-ADS - 6170000::V6.17::.\Arm Compiler 6.17 + 6180000::V6.18::.\Arm Compiler 6.18 1 diff --git a/example/main.c b/example/main.c index b98e15d..9e6b7ea 100644 --- a/example/main.c +++ b/example/main.c @@ -20,12 +20,6 @@ #include #include "perf_counter.h" -#if defined(__clang__) -# pragma clang diagnostic ignored "-Wcompound-token-split-by-macro" -#elif defined(__IS_COMPILER_GCC__) -# pragma GCC diagnostic ignored "-Wpedantic" -#endif - #ifndef __PERF_CNT_USE_LONG_CLOCK__ #include @@ -74,6 +68,7 @@ static example_lv0_t s_tItem[8] = { *----------------------------------------------------------------------------*/ int main (void) { + int32_t iCycleResult = 0; /*! demo of using() block */ using(int a = 0,printf("========= On Enter =======\r\n"), @@ -91,9 +86,7 @@ int main (void) printf("Processing item with ID = %d\r\n", _->chID); } } - - int32_t iCycleResult = 0; - + /* measure cycles and store it in a dedicated variable without printf */ __cycleof__("delay_us(1000ul)", /* insert code to __cycleof__ body, "{}" can be omitted */ diff --git a/lib/libperf_counter_gcc.a b/lib/libperf_counter_gcc.a index d718cdb..9cadca0 100644 Binary files a/lib/libperf_counter_gcc.a and b/lib/libperf_counter_gcc.a differ diff --git a/lib/perf_counter.h b/lib/perf_counter.h index 59700fe..583cb6c 100644 --- a/lib/perf_counter.h +++ b/lib/perf_counter.h @@ -104,7 +104,7 @@ extern "C" { #endif #ifndef __PLOOC_VA_NUM_ARGS_IMPL -# define __PLOOC_VA_NUM_ARGS_IMPL( _0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11, \ +# define __PLOOC_VA_NUM_ARGS_IMPL( _0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11, \ _12,_13,_14,_15,_16,__N,...) __N #endif @@ -115,7 +115,7 @@ extern "C" { #endif #ifndef UNUSED_PARAM -# define UNUSED_PARAM(__VAR) (__VAR) = (__VAR) +# define UNUSED_PARAM(__VAR) (void)(__VAR) #endif #undef __CONNECT2 @@ -170,9 +170,6 @@ extern "C" { #define CONNECT(...) \ ALT_CONNECT2(CONNECT, __PLOOC_VA_NUM_ARGS(__VA_ARGS__))(__VA_ARGS__) - - - #undef __using1 #undef __using2 #undef __using3 diff --git a/lib/perf_counter.lib b/lib/perf_counter.lib index 7c9f79a..62f25c9 100644 Binary files a/lib/perf_counter.lib and b/lib/perf_counter.lib differ diff --git a/perf_counter.c b/perf_counter.c index 5097e87..309e943 100644 --- a/perf_counter.c +++ b/perf_counter.c @@ -61,14 +61,12 @@ #define __IOM volatile /*! Defines 'read / write' structure member permissions */ /* Memory mapping of Core Hardware */ -#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ -#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ -#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ - -#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ -#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ - +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ /* SysTick Control / Status Register Definitions */ #define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ @@ -103,9 +101,6 @@ /*@} end of group CMSIS_SysTick */ - - - #define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ #define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ @@ -200,21 +195,21 @@ __STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) { if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) { - return (1UL); /* Reload value impossible */ + return (1UL); /* Reload value impossible */ } //__IRQ_SAFE { SysTick->CTRL = 0; - SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ - //NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ - SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + //NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk | - SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ //SCB->ICSR = SCB_ICSR_PENDSTCLR_Msk; //} - return (0UL); /* Function successful */ + return (0UL); /* Function successful */ } void user_code_insert_to_systick_handler(void) @@ -263,7 +258,8 @@ void init_cycle_counter(bool bSysTickIsOccupied) #if defined(__IS_COMPILER_ARM_COMPILER_5__) \ || defined(__IS_COMPILER_ARM_COMPILER_6__) \ - || defined(__IS_COMPILER_GCC__) + || defined(__IS_COMPILER_GCC__) \ + || defined(__IS_COMPILER_LLVM__) extern void __ensure_systick_wrapper(void); __ensure_systick_wrapper(); #endif @@ -657,20 +653,22 @@ int64_t __stop_task_cycle_counter(task_cycle_info_t *ptInfo) } int64_t lCycles = 0; - int64_t lCycleUsed; - __IRQ_SAFE { - lCycleUsed = get_system_ticks() - ptRootAgent->lLastTimeStamp; - lCycles = ptRootAgent->tInfo.lUsedTotal + lCycleUsed; - } - if (NULL != ptInfo) { - if (ptInfo->bEnabled) { - ptInfo->nUsedRecent = lCycleUsed; - ptInfo->lUsedTotal += lCycleUsed; - ptInfo->bEnabled = false; + __IRQ_SAFE { + int64_t lCycleUsed = get_system_ticks() - ptRootAgent->lLastTimeStamp; + ptRootAgent->tInfo.lUsedTotal += lCycleUsed; + + if (NULL != ptInfo) { + if (ptInfo->bEnabled) { + ptInfo->nUsedRecent = lCycleUsed; + ptInfo->lUsedTotal += lCycleUsed; + ptInfo->bEnabled = false; + } + + lCycles = ptInfo->lUsedTotal; + } else { + lCycles = ptRootAgent->tInfo.lUsedTotal; } - - return ptInfo->lUsedTotal; } return lCycles; diff --git a/perf_counter.h b/perf_counter.h index 59700fe..583cb6c 100644 --- a/perf_counter.h +++ b/perf_counter.h @@ -104,7 +104,7 @@ extern "C" { #endif #ifndef __PLOOC_VA_NUM_ARGS_IMPL -# define __PLOOC_VA_NUM_ARGS_IMPL( _0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11, \ +# define __PLOOC_VA_NUM_ARGS_IMPL( _0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11, \ _12,_13,_14,_15,_16,__N,...) __N #endif @@ -115,7 +115,7 @@ extern "C" { #endif #ifndef UNUSED_PARAM -# define UNUSED_PARAM(__VAR) (__VAR) = (__VAR) +# define UNUSED_PARAM(__VAR) (void)(__VAR) #endif #undef __CONNECT2 @@ -170,9 +170,6 @@ extern "C" { #define CONNECT(...) \ ALT_CONNECT2(CONNECT, __PLOOC_VA_NUM_ARGS(__VA_ARGS__))(__VA_ARGS__) - - - #undef __using1 #undef __using2 #undef __using3