mirror of
https://github.com/GorgonMeducer/perf_counter.git
synced 2025-01-17 19:13:03 +08:00
v2.2.2
This commit is contained in:
parent
a4af16ddf2
commit
9e6e1f12ec
2
Doxyfile
2
Doxyfile
@ -38,7 +38,7 @@ PROJECT_NAME = perf_counter
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = v2.2.2-dev
|
||||
PROJECT_NUMBER = v2.2.2
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
|
@ -16,8 +16,9 @@
|
||||
<repository type="git">https://github.com/GorgonMeducer/perf_counter.git</repository>
|
||||
|
||||
<releases>
|
||||
<release date="2023-05-23" version="2.2.2-dev" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.2.2.2-dev.pack">
|
||||
<release date="2023-06-12" version="2.2.2" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.2.2.2.pack">
|
||||
- Add __cpu_time__
|
||||
- Support reconfiguring the SysTick
|
||||
- Suppress warnings
|
||||
- Other minor updates
|
||||
</release>
|
||||
|
27
README.md
27
README.md
@ -1,4 +1,4 @@
|
||||
# perf_counter (v2.2.2-dev)
|
||||
# perf_counter (v2.2.2)
|
||||
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:
|
||||
@ -29,6 +29,9 @@ A dedicated performance counter for Cortex-M Systick. It shares the SysTick with
|
||||
- `delay_us()` and `delay_ms()`
|
||||
- Provides Timestamp services via `get_system_ticks()`, `get_system_us` and `get_system_ms()`.
|
||||
- **Support both RTOS and bare-metal environments**
|
||||
- Support SysTick Reconfiguration
|
||||
- Support changing System Frequency
|
||||
|
||||
- **Utilities for C language enhancement**
|
||||
- Macros to detect compilers, e.g. `__IS_COMPILER_ARM_COMPILER_6__`, `__IS_COMPILER_LLVM__` etc.
|
||||
- Macro to create atomicity for specified code block, i.e. `__IRQ_SAFE{...}`
|
||||
@ -209,6 +212,28 @@ Please set the macro `EVENT_TIMESTAMP_SOURCE` to `3` to suppress it.
|
||||
|
||||
|
||||
|
||||
### 1.5 On System Environment Changing
|
||||
|
||||
#### 1.5.1 System Frequency Changing
|
||||
|
||||
If you want to change the System Frequency, **after** the changing, make sure:
|
||||
|
||||
1. The `SystemCoreClock` has been updated with the new system frequency. Usually the HAL will update the `SystemCoreClock` automatically, but in some rare case where `SystemCoreClock` is updated accordingly, you should do it yourself.
|
||||
|
||||
2. please call `update_perf_counter()` to notify perf_counter.
|
||||
|
||||
|
||||
|
||||
#### 1.5.2 Reconfigure the SysTick
|
||||
|
||||
Some systems (e.g. FreeRTOS) might reconfigure the systick timer to fulfil the requirement of their feature. To support this:
|
||||
|
||||
1. **Before the reconfiguration**, please call function `before_cycle_counter_reconfiguration()`.
|
||||
|
||||
**NOTE**: This function will stop the SysTick, clear the pending bit, and set the Load register and the Current Value registers to zero.
|
||||
|
||||
2. After the reconfiguration, please call `update_perf_counter()` to notify perf_counter the new changes.
|
||||
|
||||
|
||||
|
||||
## 2. How To Deploy
|
||||
|
Binary file not shown.
@ -16,8 +16,9 @@
|
||||
<repository type="git">https://github.com/GorgonMeducer/perf_counter.git</repository>
|
||||
|
||||
<releases>
|
||||
<release date="2023-05-23" version="2.2.2-dev" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.2.2.2-dev.pack">
|
||||
<release date="2023-06-12" version="2.2.2" url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/GorgonMeducer.perf_counter.2.2.2.pack">
|
||||
- Add __cpu_time__
|
||||
- Support reconfiguring the SysTick
|
||||
- Suppress warnings
|
||||
- Other minor updates
|
||||
</release>
|
||||
|
@ -2,8 +2,8 @@
|
||||
<index schemaVersion="1.0.0" xs:noNamespaceSchemaLocation="PackIndex.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<vendor>GorgonMeducer</vendor>
|
||||
<url>https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/</url>
|
||||
<timestamp>2023-05-19T08:21:00</timestamp>
|
||||
<timestamp>2023-06-12T08:36:00</timestamp>
|
||||
<pindex>
|
||||
<pdsc url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/" vendor="GorgonMeducer" name="perf_counter" version="2.2.1"/>
|
||||
<pdsc url="https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/" vendor="GorgonMeducer" name="perf_counter" version="2.2.2"/>
|
||||
</pindex>
|
||||
</index>
|
||||
|
@ -9,12 +9,12 @@
|
||||
|
||||
<project>
|
||||
<PathAndName>.\example.uvprojx</PathAndName>
|
||||
<NodeIsActive>1</NodeIsActive>
|
||||
<NodeIsExpanded>1</NodeIsExpanded>
|
||||
</project>
|
||||
|
||||
<project>
|
||||
<PathAndName>.\gcc_example.uvprojx</PathAndName>
|
||||
<NodeIsActive>1</NodeIsActive>
|
||||
</project>
|
||||
|
||||
</ProjectWorkspace>
|
||||
|
@ -75,7 +75,7 @@
|
||||
<OPTFL>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>1</IsCurrentTarget>
|
||||
<IsCurrentTarget>0</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
<CpuCode>7</CpuCode>
|
||||
<DebugOpt>
|
||||
@ -297,7 +297,7 @@
|
||||
<OPTFL>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>0</IsCurrentTarget>
|
||||
<IsCurrentTarget>1</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
<CpuCode>7</CpuCode>
|
||||
<DebugOpt>
|
||||
|
Binary file not shown.
@ -37,7 +37,7 @@ extern "C" {
|
||||
#define __PERF_COUNTER_VER_MINOR__ 2
|
||||
#define __PERF_COUNTER_VER_REVISE__ 2
|
||||
|
||||
#define __PERF_COUNTER_VER_STR__ "dev"
|
||||
#define __PERF_COUNTER_VER_STR__ ""
|
||||
|
||||
#define __PER_COUNTER_VER__ (__PERF_COUNTER_VER_MAJOR__ * 10000ul \
|
||||
+__PERF_COUNTER_VER_MINOR__ * 100ul \
|
||||
@ -338,8 +338,8 @@ __asm(".global __ensure_systick_wrapper\n\t");
|
||||
})
|
||||
|
||||
/*!
|
||||
* \brief measure the cpu usage for a given code segment and print out the
|
||||
* result in percentage.
|
||||
* \brief measure the cpu usage for a given code segment and print out the
|
||||
* result in percentage.
|
||||
* \param[in] __CNT generate result on every given iterations
|
||||
* \param[in] ... an optional code segement, in which we can read the measured
|
||||
* result from __usage__ which is a float value.
|
||||
@ -450,7 +450,7 @@ __asm(".global __ensure_systick_wrapper\n\t");
|
||||
* \return bool whether it is timeout
|
||||
*/
|
||||
#define perfc_is_time_out_us3(__us, __timestamp_ptr, __auto_reload) \
|
||||
({ static int64_t SAFE_NAME(s_lTimestamp); (void)SAFE_NAME(s_lTimestamp) \
|
||||
({ static int64_t SAFE_NAME(s_lTimestamp); (void)SAFE_NAME(s_lTimestamp); \
|
||||
__perfc_is_time_out(perfc_convert_us_to_ticks(__us), \
|
||||
(__timestamp_ptr), (__auto_reload));})
|
||||
|
||||
@ -657,8 +657,8 @@ extern void delay_us(int32_t nUs);
|
||||
*/
|
||||
extern void delay_ms(int32_t nMs);
|
||||
|
||||
/*!
|
||||
* \brief convert ticks of a reference timer to millisecond
|
||||
/*!
|
||||
* \brief convert ticks of a reference timer to millisecond
|
||||
*
|
||||
* \param[in] lTick the tick count
|
||||
* \return int64_t the millisecond
|
||||
@ -666,8 +666,8 @@ extern void delay_ms(int32_t nMs);
|
||||
extern
|
||||
int64_t perfc_convert_ticks_to_ms(int64_t lTick);
|
||||
|
||||
/*!
|
||||
* \brief convert millisecond into ticks of the reference timer
|
||||
/*!
|
||||
* \brief convert millisecond into ticks of the reference timer
|
||||
*
|
||||
* \param[in] wMS the target time in millisecond
|
||||
* \return int64_t the ticks
|
||||
@ -675,8 +675,8 @@ int64_t perfc_convert_ticks_to_ms(int64_t lTick);
|
||||
extern
|
||||
int64_t perfc_convert_ms_to_ticks(uint32_t wMS);
|
||||
|
||||
/*!
|
||||
* \brief convert ticks of a reference timer to microsecond
|
||||
/*!
|
||||
* \brief convert ticks of a reference timer to microsecond
|
||||
*
|
||||
* \param[in] lTick the tick count
|
||||
* \return int64_t the microsecond
|
||||
@ -684,8 +684,8 @@ int64_t perfc_convert_ms_to_ticks(uint32_t wMS);
|
||||
extern
|
||||
int64_t perfc_convert_ticks_to_us(int64_t lTick);
|
||||
|
||||
/*!
|
||||
* \brief convert microsecond into ticks of the reference timer
|
||||
/*!
|
||||
* \brief convert microsecond into ticks of the reference timer
|
||||
*
|
||||
* \param[in] wUS the target time in microsecond
|
||||
* \return int64_t the ticks
|
||||
@ -695,9 +695,9 @@ int64_t perfc_convert_us_to_ticks(uint32_t wUS);
|
||||
|
||||
/*!
|
||||
* \brief set an alarm with given period and check the status
|
||||
*
|
||||
*
|
||||
* \param[in] lPeriod a time period in ticks
|
||||
* \param[in] plTimestamp a pointer points to an int64_t integer, if NULL is
|
||||
* \param[in] plTimestamp a pointer points to an int64_t integer, if NULL is
|
||||
* passed, an static local variable inside the function will be used
|
||||
* \param[in] bAutoReload whether starting next period after a timeout event.
|
||||
* \return bool whether it is timeout or not
|
||||
@ -762,7 +762,7 @@ extern bool disable_task_cycle_info(task_cycle_info_t *ptInfo);
|
||||
extern
|
||||
void resume_task_cycle_info(task_cycle_info_t *ptInfo, bool bEnabledStatus);
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* \brief register a global virtual cycle counter agent to the current task
|
||||
* \param[in] ptInfo the address of target task_cycle_info_t object
|
||||
* \param[in] ptAgent an list node for the task_cycle_info_t object
|
||||
@ -872,7 +872,7 @@ extern void init_cycle_counter(bool bIsSysTickOccupied);
|
||||
|
||||
/*!
|
||||
* \brief a system timer handler inserted to the SysTick_Handler
|
||||
*
|
||||
*
|
||||
* \note - if you are using a compiler other than armcc or armclang, e.g. iar,
|
||||
* arm gcc etc, the systick_wrapper_ual.o doesn't work with the linker
|
||||
* of your target toolchain as it use the $Super$$ which is only supported
|
||||
@ -891,6 +891,22 @@ extern void user_code_insert_to_systick_handler(void);
|
||||
*/
|
||||
extern void update_perf_counter(void);
|
||||
|
||||
/*!
|
||||
* \brief prepare for reconfiguration of SysTick timer.
|
||||
*
|
||||
* \note some systems (e.g. FreeRTOS) might reconfigure the systick timer to
|
||||
* fulfil the requirement of their feature. To support this, just
|
||||
* before the reconfiguration, please call this function in order
|
||||
* to make the perf_counter works correctly later.
|
||||
*
|
||||
* \note after the reconfiguration, please call update_perf_counter() to apply
|
||||
* the changes to perf_counter.
|
||||
*
|
||||
* \note this function will stop the SysTick, clear the pending bit and set
|
||||
* the Load register and Current Value register to zero.
|
||||
*/
|
||||
extern void before_cycle_counter_reconfiguration(void);
|
||||
|
||||
/*! @} */
|
||||
|
||||
/*!
|
||||
|
Binary file not shown.
@ -300,6 +300,26 @@ __STATIC_INLINE int32_t check_systick(void)
|
||||
return nTemp;
|
||||
}
|
||||
|
||||
void before_cycle_counter_reconfiguration(void)
|
||||
{
|
||||
__IRQ_SAFE {
|
||||
SysTick->CTRL = 0; /* disable SysTick first */
|
||||
|
||||
if (SCB->ICSR & SCB_ICSR_PENDSTSET_Msk) { /* pending SysTick exception */
|
||||
SCB->ICSR = SCB_ICSR_PENDSTCLR_Msk; /* clear pending bit */
|
||||
|
||||
user_code_insert_to_systick_handler(); /* manually handle exception */
|
||||
|
||||
}
|
||||
s_lSystemClockCounts = check_systick(); /* get the final cycle counter value */
|
||||
|
||||
SysTick->LOAD = 0UL;
|
||||
SysTick->VAL = 0UL; /* clear the Current Value Register */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
__attribute__((constructor))
|
||||
void __perf_counter_init(void)
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ extern "C" {
|
||||
#define __PERF_COUNTER_VER_MINOR__ 2
|
||||
#define __PERF_COUNTER_VER_REVISE__ 2
|
||||
|
||||
#define __PERF_COUNTER_VER_STR__ "dev"
|
||||
#define __PERF_COUNTER_VER_STR__ ""
|
||||
|
||||
#define __PER_COUNTER_VER__ (__PERF_COUNTER_VER_MAJOR__ * 10000ul \
|
||||
+__PERF_COUNTER_VER_MINOR__ * 100ul \
|
||||
@ -891,6 +891,22 @@ extern void user_code_insert_to_systick_handler(void);
|
||||
*/
|
||||
extern void update_perf_counter(void);
|
||||
|
||||
/*!
|
||||
* \brief prepare for reconfiguration of SysTick timer.
|
||||
*
|
||||
* \note some systems (e.g. FreeRTOS) might reconfigure the systick timer to
|
||||
* fulfil the requirement of their feature. To support this, just
|
||||
* before the reconfiguration, please call this function in order
|
||||
* to make the perf_counter works correctly later.
|
||||
*
|
||||
* \note after the reconfiguration, please call update_perf_counter() to apply
|
||||
* the changes to perf_counter.
|
||||
*
|
||||
* \note this function will stop the SysTick, clear the pending bit and set
|
||||
* the Load register and Current Value register to zero.
|
||||
*/
|
||||
extern void before_cycle_counter_reconfiguration(void);
|
||||
|
||||
/*! @} */
|
||||
|
||||
/*!
|
||||
|
Loading…
x
Reference in New Issue
Block a user