This commit is contained in:
Gabriel Wang 2021-12-20 20:00:36 +00:00
parent bb56d45fae
commit e039a3031d
7 changed files with 108 additions and 2 deletions

View File

@ -167,6 +167,10 @@
<files>
<file category="source" name="lib/perf_os_patch_rtx5.c"/>
</files>
<Pre_Include_Global_h>
//! \brief Enable RTOS Patch for perf_counter
#define __PERF_CNT_USE_RTOS__
</Pre_Include_Global_h>
</component>
</components>

Binary file not shown.

View File

@ -16,6 +16,10 @@
<repository type="git">https://github.com/GorgonMeducer/perf_counter.git</repository>
<releases>
<release date="2021-12-20" version="1.7.0" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.1.7.0.pack">
- Add new feature for RTOS. Now you can get cycle information for the current thread.
- Other minor update
</release>
<release date="2021-12-05" version="1.6.5" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.1.6.5.pack">
- Include stddef.h in perf_counter.h to solve missing NULL definition issue.
</release>
@ -77,6 +81,11 @@
<require Cclass="CMSIS" Cgroup="CORE"/>
</condition>
<condition id="RTX5">
<description>Require RTX5 Support</description>
<accept Cclass="CMSIS" Cgroup="RTOS2" Csub="Keil RTX5" Cvariant="Source"/>
</condition>
<condition id="Cortex-M Arm GCC">
<description>Compile Cortex-M Processors with GNU Tools for Arm Embedded Processors.</description>
<require condition="Arm GCC"/>
@ -101,6 +110,7 @@
<require condition="CMSIS-CORE"/>
</condition>
</conditions>
<!-- apis section (optional - for Application Programming Interface descriptions) -->
<!--
@ -133,7 +143,7 @@
-->
<components>
<component Cclass="Utilities" Cgroup="Performance" Csub="perf_counter" Cvariant="Library" Cversion="1.6.5" isDefaultVariant="true">
<component Cclass="Utilities" Cgroup="Performance" Csub="perf_counter" Cvariant="Library" Cversion="1.7.0" isDefaultVariant="true">
<description>A dedicated performance counter for Cortex-M systick.</description>
<files>
<file category="header" name="lib/perf_counter.h"/>
@ -141,7 +151,8 @@
<file category="library" name="lib/libperf_counter_gcc.a" condition="Cortex-M Arm GCC"/>
</files>
</component>
<component Cclass="Utilities" Cgroup="Performance" Csub="perf_counter" Cvariant="Source" Cversion="1.6.5" condition="CMSIS-CORE">
<component Cclass="Utilities" Cgroup="Performance" Csub="perf_counter" Cvariant="Source" Cversion="1.7.0" condition="CMSIS-CORE">
<description>A dedicated performance counter for Cortex-M systick.</description>
<files>
<file category="header" name="lib/perf_counter.h"/>
@ -150,6 +161,17 @@
<file category="source" name="systick_wrapper_gcc.s" condition="Cortex-M Arm GCC CMSIS-CORE"/>
</files>
</component>
<component Cclass="Utilities" Cgroup="Performance" Csub="RTX5 Patch" Cversion="1.7.0" condition="RTX5">
<description>A Patch for RTX5</description>
<files>
<file category="source" name="lib/perf_os_patch_rtx5.c"/>
</files>
<Pre_Include_Global_h>
//! \brief Enable RTOS Patch for perf_counter
#define __PERF_CNT_USE_RTOS__
</Pre_Include_Global_h>
</component>
</components>
<!-- optional taxonomy section for defining new component Class and Group names -->

View File

@ -319,6 +319,7 @@ __attribute__((nothrow))
extern int64_t get_system_ticks(void);
#if defined(__PERF_CNT_USE_RTOS__)
/*! \brief provide cycle information for target task if perf_counter is used
*! together with an RTOS in the support list.
*!
@ -327,6 +328,25 @@ extern int64_t get_system_ticks(void);
*/
extern task_cycle_info_t * get_rtos_task_cycle_info(void);
/*! \brief start cycle counter for current task
*/
extern void start_task_cycle_counter(void);
/*! \brief calculate the elapsed cycle count for current task since the last
*! start point
*!
*! \note you can have multiple stop_cycle_counter following one start point
*!
*! \return the elapsed cycle count.
*/
extern int32_t stop_task_cycle_counter(void);
#else
# define start_task_cycle_counter start_cycle_counter
# define stop_task_cycle_counter stop_cycle_counter
#endif
/*----------------------------------------------------------------------------*
* Please ignore the following APIs unless you have encountered some known *

View File

@ -116,3 +116,23 @@ task_cycle_info_t * get_rtos_task_cycle_info(void)
return &(((struct __task_cycle_info_t *)curr->stack_mem)->tInfo);
}
void start_task_cycle_counter(void)
{
task_cycle_info_t * ptInfo = get_rtos_task_cycle_info();
if (NULL != ptInfo) {
ptInfo->dwUsedTotal = 0;
}
}
int32_t stop_task_cycle_counter(void)
{
task_cycle_info_t * ptInfo = get_rtos_task_cycle_info();
if (NULL != ptInfo) {
return (int32_t)ptInfo->dwUsedTotal;
}
return 0;
}

View File

@ -319,6 +319,7 @@ __attribute__((nothrow))
extern int64_t get_system_ticks(void);
#if defined(__PERF_CNT_USE_RTOS__)
/*! \brief provide cycle information for target task if perf_counter is used
*! together with an RTOS in the support list.
*!
@ -327,6 +328,25 @@ extern int64_t get_system_ticks(void);
*/
extern task_cycle_info_t * get_rtos_task_cycle_info(void);
/*! \brief start cycle counter for current task
*/
extern void start_task_cycle_counter(void);
/*! \brief calculate the elapsed cycle count for current task since the last
*! start point
*!
*! \note you can have multiple stop_cycle_counter following one start point
*!
*! \return the elapsed cycle count.
*/
extern int32_t stop_task_cycle_counter(void);
#else
# define start_task_cycle_counter start_cycle_counter
# define stop_task_cycle_counter stop_cycle_counter
#endif
/*----------------------------------------------------------------------------*
* Please ignore the following APIs unless you have encountered some known *

View File

@ -116,3 +116,23 @@ task_cycle_info_t * get_rtos_task_cycle_info(void)
return &(((struct __task_cycle_info_t *)curr->stack_mem)->tInfo);
}
void start_task_cycle_counter(void)
{
task_cycle_info_t * ptInfo = get_rtos_task_cycle_info();
if (NULL != ptInfo) {
ptInfo->dwUsedTotal = 0;
}
}
int32_t stop_task_cycle_counter(void)
{
task_cycle_info_t * ptInfo = get_rtos_task_cycle_info();
if (NULL != ptInfo) {
return (int32_t)ptInfo->dwUsedTotal;
}
return 0;
}