This commit is contained in:
Gabriel Wang 2022-09-24 20:07:10 +01:00
parent 16111dfb7c
commit 0e55f3db74
13 changed files with 121 additions and 165 deletions

View File

@ -16,7 +16,9 @@
<repository type="git">https://github.com/GorgonMeducer/perf_counter.git</repository>
<releases>
<release date="2022-09-05" version="1.9.9-dev" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.1.9.9-dev.pack">
<release date="2022-09-24" version="1.9.9" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.1.9.9.pack">
- Improve the way to import systick wrapper
- Add get_system_us to avoid 64bit integer divider.
- Minor Update
</release>
<release date="2022-08-10" version="1.9.8" url="https://github.com/GorgonMeducer/perf_counter/raw/fbc8e94b0d78abb959462350d15df6885be70d27/cmsis-pack/GorgonMeducer.perf_counter.1.9.8.pack">

View File

@ -1,4 +1,4 @@
# perf_counter (v1.9.8)
# perf_counter (v1.9.9)
A dedicated performance counter for Cortex-M Systick. It shares the SysTick with users' original SysTick function(s) without interfering with it. This library will bring new functionalities, such as performance counter,` delay_us` and `clock()` service defined in `time.h`.
### Features:
@ -28,7 +28,7 @@ A dedicated performance counter for Cortex-M Systick. It shares the SysTick with
- **RT-Thread package is avaialble**
- **Time based services**
- `delay_us()` and `delay_ms()`
- Provides Timestamp services via ***get_system_ticks()*** and `get_system_ms()`
- Provides Timestamp services via `get_system_ticks()`, `get_system_us` and `get_system_ms()`.
- **Support both RTOS and bare-metal environments**
- **Utilities for C language enhancement**
- Macros to detect compilers, e.g. `__IS_COMPILER_ARM_COMPILER_6__`, `__IS_COMPILER_LLVM__` etc.

View File

@ -16,7 +16,9 @@
<repository type="git">https://github.com/GorgonMeducer/perf_counter.git</repository>
<releases>
<release date="2022-09-05" version="1.9.9-dev" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.1.9.9-dev.pack">
<release date="2022-09-24" version="1.9.9" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.1.9.9.pack">
- Improve the way to import systick wrapper
- Add get_system_us to avoid 64bit integer divider.
- Minor Update
</release>
<release date="2022-08-10" version="1.9.8" url="https://github.com/GorgonMeducer/perf_counter/raw/fbc8e94b0d78abb959462350d15df6885be70d27/cmsis-pack/GorgonMeducer.perf_counter.1.9.8.pack">

View File

@ -606,70 +606,6 @@
<ExecCommand></ExecCommand>
<Expression>0x00000CC2</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>0</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>1486</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename></Filename>
<ExecCommand></ExecCommand>
<Expression>0x000005CE</Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>1</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>C:\Work\SVN\projects\MCU\perf_counter_library\example\main.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
<Bp>
<Number>3</Number>
<Type>0</Type>
<LineNumber>1</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>C:\Work\SVN\projects\MCU\perf_counter_library\example\platform.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
<Bp>
<Number>4</Number>
<Type>0</Type>
<LineNumber>1</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>C:\Work\SVN\projects\MCU\perf_counter_library\example\stdout_USART.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
</Breakpoint>
<WatchWindow1>
<Ww>
@ -865,7 +801,7 @@
<Group>
<GroupName>::Compiler</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>1</RteFlg>

View File

@ -333,7 +333,7 @@
<v6LangP>3</v6LangP>
<vShortEn>1</vShortEn>
<vShortWch>1</vShortWch>
<v6Lto>0</v6Lto>
<v6Lto>1</v6Lto>
<v6WtE>0</v6WtE>
<v6Rtti>0</v6Rtti>
<VariousControls>
@ -858,7 +858,7 @@
<v6Rtti>0</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define>__PERF_COUNTER_CFG_USE_SYSTICK_WRAPPER__</Define>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
@ -1708,8 +1708,8 @@
<RTE>
<apis/>
<components>
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.5.0" condition="ARMv6_7_8-M Device">
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.0"/>
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.6.0" condition="ARMv6_7_8-M Device">
<package name="CMSIS" schemaVersion="1.7.7" url="http://www.keil.com/pack/" vendor="ARM" version="5.9.0"/>
<targetInfos>
<targetInfo name="example_arm compiler_5"/>
<targetInfo name="example_arm_compiler_6"/>
@ -1717,7 +1717,7 @@
</targetInfos>
</component>
<component Cclass="Device" Cgroup="Startup" Cvendor="ARM" Cversion="1.2.2" condition="ARMCM0 CMSIS">
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.0"/>
<package name="CMSIS" schemaVersion="1.7.7" url="http://www.keil.com/pack/" vendor="ARM" version="5.9.0"/>
<targetInfos>
<targetInfo name="example_arm compiler_5"/>
<targetInfo name="example_arm_compiler_6"/>
@ -1725,7 +1725,7 @@
</targetInfos>
</component>
<component Cbundle="ARM Compiler" Cclass="Compiler" Cgroup="I/O" Csub="STDOUT" Cvariant="User" Cvendor="Keil" Cversion="1.2.0" condition="ARMCC Cortex-M" isTargetSpecific="1">
<package name="ARM_Compiler" schemaVersion="1.6.3" url="http://www.keil.com/pack/" vendor="Keil" version="1.6.3"/>
<package name="ARM_Compiler" schemaVersion="1.7.7" url="https://www.keil.com/pack/" vendor="Keil" version="1.7.2"/>
<targetInfos>
<targetInfo name="example_arm compiler_5"/>
<targetInfo name="example_arm_compiler_6"/>

View File

@ -125,7 +125,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>DLGTARM</Key>
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)</Name>
<Name>(1010=-1,-1,-1,-1,0)(1007=105,137,312,358,1)(1008=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
@ -549,6 +549,18 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>3</GroupNumber>
<FileNumber>9</FileNumber>
<FileType>4</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\lib\libperf_counter_gcc.a</PathWithFileName>
<FilenameWithoutPath>libperf_counter_gcc.a</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
@ -559,12 +571,4 @@
<RteFlg>1</RteFlg>
</Group>
<Group>
<GroupName>::Utilities</GroupName>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>1</RteFlg>
</Group>
</ProjectOpt>

View File

@ -244,7 +244,7 @@
<MiscControls></MiscControls>
<Define>__PERF_COUNTER_CFG_USE_SYSTICK_WRAPPER__</Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
<IncludePath>..\..\perf_counter_library</IncludePath>
</VariousControls>
</Carm>
<Aarm>
@ -398,61 +398,16 @@
</FileArm>
</FileOption>
</File>
<File>
<FileName>libperf_counter_gcc.a</FileName>
<FileType>4</FileType>
<FilePath>..\lib\libperf_counter_gcc.a</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>::CMSIS</GroupName>
</Group>
<Group>
<GroupName>::Utilities</GroupName>
<GroupOption>
<CommonProperty>
<UseCPPCompiler>0</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>0</IncludeInBuild>
<AlwaysBuild>2</AlwaysBuild>
<GenerateAssemblyFile>2</GenerateAssemblyFile>
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<GroupArm>
<Carm>
<arpcs>2</arpcs>
<stkchk>2</stkchk>
<reentr>2</reentr>
<interw>2</interw>
<bigend>2</bigend>
<Strict>0</Strict>
<Optim>0</Optim>
<wLevel>0</wLevel>
<uThumb>2</uThumb>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Carm>
<Aarm>
<bBE>2</bBE>
<interw>2</interw>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Aarm>
</GroupArm>
</GroupOption>
</Group>
</Groups>
</Target>
<Target>
@ -691,7 +646,7 @@
<uThumb>1</uThumb>
<VariousControls>
<MiscControls></MiscControls>
<Define>__PERF_COUNTER_CFG_USE_SYSTICK_WRAPPER__</Define>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
@ -873,14 +828,35 @@
<FileType>2</FileType>
<FilePath>..\systick_wrapper_gcc.s</FilePath>
</File>
<File>
<FileName>libperf_counter_gcc.a</FileName>
<FileType>4</FileType>
<FilePath>..\lib\libperf_counter_gcc.a</FilePath>
<FileOption>
<CommonProperty>
<UseCPPCompiler>2</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>0</IncludeInBuild>
<AlwaysBuild>2</AlwaysBuild>
<GenerateAssemblyFile>2</GenerateAssemblyFile>
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArm/>
</FileOption>
</File>
</Files>
</Group>
<Group>
<GroupName>::CMSIS</GroupName>
</Group>
<Group>
<GroupName>::Utilities</GroupName>
</Group>
</Groups>
</Target>
</Targets>
@ -888,20 +864,13 @@
<RTE>
<apis/>
<components>
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.5.0" condition="ARMv6_7_8-M Device">
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.1"/>
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.6.0" condition="ARMv6_7_8-M Device">
<package name="CMSIS" schemaVersion="1.7.7" url="http://www.keil.com/pack/" vendor="ARM" version="5.9.0"/>
<targetInfos>
<targetInfo name="example"/>
<targetInfo name="gcc_lib"/>
</targetInfos>
</component>
<component Cbundle="Performance Counter" Cclass="Utilities" Cgroup="perf_counter" Csub="Core" Cvariant="Library" Cvendor="GorgonMeducer" Cversion="1.7.7" isTargetSpecific="1">
<package name="perf_counter" schemaVersion="1.4" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/" vendor="GorgonMeducer" version="1.7.7"/>
<targetInfos>
<targetInfo excluded="1" name="example"/>
<targetInfo name="gcc_lib"/>
</targetInfos>
</component>
</components>
<files>
<file attr="config" category="linkerScript" condition="GCC" name="Device\ARM\ARMCM0\Source\GCC\gcc_arm.ld" version="2.1.0">

Binary file not shown.

View File

@ -37,7 +37,7 @@ extern "C" {
#define __PERF_COUNTER_VER_MINOR__ 9
#define __PERF_COUNTER_VER_REVISE__ 9
#define __PERF_COUNTER_VER_STR__ "dev"
#define __PERF_COUNTER_VER_STR__ "rel"
#define __PER_COUNTER_VER__ (__PERF_COUNTER_VER_MAJOR__ * 10000ul \
+__PERF_COUNTER_VER_MINOR__ * 100ul \
@ -289,6 +289,14 @@ extern "C" {
__super_loop_monitor__()
#endif
#if defined(__PERF_COUNTER_CFG_USE_SYSTICK_WRAPPER__)
# if defined(__IS_COMPILER_ARM_COMPILER_5__) && __IS_COMPILER_ARM_COMPILER_5__
# pragma import(__ensure_systick_wrapper)
# elif (defined(__GNUC__) || defined(__clang__)) \
&& (!defined(__IS_COMPILER_IAR__) || !__IS_COMPILER_IAR__)
__asm(".global __ensure_systick_wrapper\n\t");
# endif
#endif
/*! @} */
/*============================ MACROFIED FUNCTIONS ===========================*/
@ -395,6 +403,12 @@ extern int64_t get_system_ticks(void);
*/
extern int32_t get_system_ms(void);
/*!
* \brief get the elapsed microsecond since perf_counter is initialised
* \return int32_t the elapsed microsecond
*/
extern int32_t get_system_us(void);
/*!
* \brief try to set a start pointer for the performance counter
*/

Binary file not shown.

View File

@ -163,7 +163,9 @@ volatile int32_t g_nOffset = 0;
volatile static int32_t s_nUSUnit = 1;
volatile static int32_t s_nMSUnit = 1;
volatile static int32_t s_nMSResidule = 0;
volatile static int32_t s_nUSResidule = 0;
volatile static int32_t s_nSystemMS = 0;
volatile static int32_t s_nSystemUS = 0;
volatile static int64_t s_lSystemClockCounts = 0;
@ -199,10 +201,21 @@ void user_code_insert_to_systick_handler(void)
s_lSystemClockCounts += wLoad;
// update system ms counter
do {
s_nMSResidule += wLoad;
int32_t nMS = s_nMSResidule / s_nMSUnit;
s_nMSResidule -= nMS * s_nMSUnit;
s_nSystemMS += nMS;
} while(0);
// update system us counter
do {
s_nUSResidule += wLoad;
int32_t nUS = s_nUSResidule / s_nUSUnit;
s_nUSResidule -= nUS * s_nUSUnit;
s_nSystemUS += nUS;
} while(0);
}
__WEAK
@ -235,16 +248,7 @@ void init_cycle_counter(bool bIsSysTickOccupied)
update_perf_counter();
s_lSystemClockCounts = 0; // reset system cycle counter
s_nSystemMS = 0; // reset system millisecond counter
#if defined(__PERF_COUNTER_CFG_USE_SYSTICK_WRAPPER__)
#if defined(__IS_COMPILER_ARM_COMPILER_5__) \
|| defined(__IS_COMPILER_ARM_COMPILER_6__) \
|| defined(__IS_COMPILER_GCC__) \
|| defined(__IS_COMPILER_LLVM__)
extern void __ensure_systick_wrapper(void);
__ensure_systick_wrapper();
#endif
#endif
s_nSystemUS = 0; // reset system microsecond counter
__perf_os_patch_init();
}
@ -381,6 +385,17 @@ int32_t get_system_ms(void)
return nTemp;
}
int32_t get_system_us(void)
{
int32_t nTemp = 0;
__IRQ_SAFE {
nTemp = s_nSystemUS + (check_systick() + s_nUSResidule) / s_nUSUnit;
}
return nTemp;
}
__WEAK
task_cycle_info_t * get_rtos_task_cycle_info(void)
{

View File

@ -37,7 +37,7 @@ extern "C" {
#define __PERF_COUNTER_VER_MINOR__ 9
#define __PERF_COUNTER_VER_REVISE__ 9
#define __PERF_COUNTER_VER_STR__ "dev"
#define __PERF_COUNTER_VER_STR__ "rel"
#define __PER_COUNTER_VER__ (__PERF_COUNTER_VER_MAJOR__ * 10000ul \
+__PERF_COUNTER_VER_MINOR__ * 100ul \
@ -289,6 +289,14 @@ extern "C" {
__super_loop_monitor__()
#endif
#if defined(__PERF_COUNTER_CFG_USE_SYSTICK_WRAPPER__)
# if defined(__IS_COMPILER_ARM_COMPILER_5__) && __IS_COMPILER_ARM_COMPILER_5__
# pragma import(__ensure_systick_wrapper)
# elif (defined(__GNUC__) || defined(__clang__)) \
&& (!defined(__IS_COMPILER_IAR__) || !__IS_COMPILER_IAR__)
__asm(".global __ensure_systick_wrapper\n\t");
# endif
#endif
/*! @} */
/*============================ MACROFIED FUNCTIONS ===========================*/
@ -395,6 +403,12 @@ extern int64_t get_system_ticks(void);
*/
extern int32_t get_system_ms(void);
/*!
* \brief get the elapsed microsecond since perf_counter is initialised
* \return int32_t the elapsed microsecond
*/
extern int32_t get_system_us(void);
/*!
* \brief try to set a start pointer for the performance counter
*/