mirror of
https://github.com/GorgonMeducer/perf_counter.git
synced 2025-02-07 19:34:18 +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
|
# could be handy for archiving the generated documentation or if some version
|
||||||
# control system is used.
|
# 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
|
# 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
|
# 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>
|
<repository type="git">https://github.com/GorgonMeducer/perf_counter.git</repository>
|
||||||
|
|
||||||
<releases>
|
<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__
|
- Add __cpu_time__
|
||||||
|
- Support reconfiguring the SysTick
|
||||||
- Suppress warnings
|
- Suppress warnings
|
||||||
- Other minor updates
|
- Other minor updates
|
||||||
</release>
|
</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`.
|
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:
|
### Features:
|
||||||
@ -29,6 +29,9 @@ A dedicated performance counter for Cortex-M Systick. It shares the SysTick with
|
|||||||
- `delay_us()` and `delay_ms()`
|
- `delay_us()` and `delay_ms()`
|
||||||
- Provides Timestamp services via `get_system_ticks()`, `get_system_us` 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**
|
- **Support both RTOS and bare-metal environments**
|
||||||
|
- Support SysTick Reconfiguration
|
||||||
|
- Support changing System Frequency
|
||||||
|
|
||||||
- **Utilities for C language enhancement**
|
- **Utilities for C language enhancement**
|
||||||
- Macros to detect compilers, e.g. `__IS_COMPILER_ARM_COMPILER_6__`, `__IS_COMPILER_LLVM__` etc.
|
- 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{...}`
|
- 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
|
## 2. How To Deploy
|
||||||
|
Binary file not shown.
@ -16,8 +16,9 @@
|
|||||||
<repository type="git">https://github.com/GorgonMeducer/perf_counter.git</repository>
|
<repository type="git">https://github.com/GorgonMeducer/perf_counter.git</repository>
|
||||||
|
|
||||||
<releases>
|
<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__
|
- Add __cpu_time__
|
||||||
|
- Support reconfiguring the SysTick
|
||||||
- Suppress warnings
|
- Suppress warnings
|
||||||
- Other minor updates
|
- Other minor updates
|
||||||
</release>
|
</release>
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
<index schemaVersion="1.0.0" xs:noNamespaceSchemaLocation="PackIndex.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
|
<index schemaVersion="1.0.0" xs:noNamespaceSchemaLocation="PackIndex.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
<vendor>GorgonMeducer</vendor>
|
<vendor>GorgonMeducer</vendor>
|
||||||
<url>https://raw.githubusercontent.com/GorgonMeducer/perf_counter/CMSIS-Pack/cmsis-pack/</url>
|
<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>
|
<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>
|
</pindex>
|
||||||
</index>
|
</index>
|
||||||
|
@ -9,12 +9,12 @@
|
|||||||
|
|
||||||
<project>
|
<project>
|
||||||
<PathAndName>.\example.uvprojx</PathAndName>
|
<PathAndName>.\example.uvprojx</PathAndName>
|
||||||
<NodeIsActive>1</NodeIsActive>
|
|
||||||
<NodeIsExpanded>1</NodeIsExpanded>
|
<NodeIsExpanded>1</NodeIsExpanded>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
<project>
|
<project>
|
||||||
<PathAndName>.\gcc_example.uvprojx</PathAndName>
|
<PathAndName>.\gcc_example.uvprojx</PathAndName>
|
||||||
|
<NodeIsActive>1</NodeIsActive>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
</ProjectWorkspace>
|
</ProjectWorkspace>
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
<OPTFL>
|
<OPTFL>
|
||||||
<tvExp>1</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<IsCurrentTarget>1</IsCurrentTarget>
|
<IsCurrentTarget>0</IsCurrentTarget>
|
||||||
</OPTFL>
|
</OPTFL>
|
||||||
<CpuCode>7</CpuCode>
|
<CpuCode>7</CpuCode>
|
||||||
<DebugOpt>
|
<DebugOpt>
|
||||||
@ -297,7 +297,7 @@
|
|||||||
<OPTFL>
|
<OPTFL>
|
||||||
<tvExp>1</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<IsCurrentTarget>0</IsCurrentTarget>
|
<IsCurrentTarget>1</IsCurrentTarget>
|
||||||
</OPTFL>
|
</OPTFL>
|
||||||
<CpuCode>7</CpuCode>
|
<CpuCode>7</CpuCode>
|
||||||
<DebugOpt>
|
<DebugOpt>
|
||||||
|
Binary file not shown.
@ -37,7 +37,7 @@ extern "C" {
|
|||||||
#define __PERF_COUNTER_VER_MINOR__ 2
|
#define __PERF_COUNTER_VER_MINOR__ 2
|
||||||
#define __PERF_COUNTER_VER_REVISE__ 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 \
|
#define __PER_COUNTER_VER__ (__PERF_COUNTER_VER_MAJOR__ * 10000ul \
|
||||||
+__PERF_COUNTER_VER_MINOR__ * 100ul \
|
+__PERF_COUNTER_VER_MINOR__ * 100ul \
|
||||||
@ -450,7 +450,7 @@ __asm(".global __ensure_systick_wrapper\n\t");
|
|||||||
* \return bool whether it is timeout
|
* \return bool whether it is timeout
|
||||||
*/
|
*/
|
||||||
#define perfc_is_time_out_us3(__us, __timestamp_ptr, __auto_reload) \
|
#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), \
|
__perfc_is_time_out(perfc_convert_us_to_ticks(__us), \
|
||||||
(__timestamp_ptr), (__auto_reload));})
|
(__timestamp_ptr), (__auto_reload));})
|
||||||
|
|
||||||
@ -891,6 +891,22 @@ extern void user_code_insert_to_systick_handler(void);
|
|||||||
*/
|
*/
|
||||||
extern void update_perf_counter(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;
|
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))
|
__attribute__((constructor))
|
||||||
void __perf_counter_init(void)
|
void __perf_counter_init(void)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,7 @@ extern "C" {
|
|||||||
#define __PERF_COUNTER_VER_MINOR__ 2
|
#define __PERF_COUNTER_VER_MINOR__ 2
|
||||||
#define __PERF_COUNTER_VER_REVISE__ 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 \
|
#define __PER_COUNTER_VER__ (__PERF_COUNTER_VER_MAJOR__ * 10000ul \
|
||||||
+__PERF_COUNTER_VER_MINOR__ * 100ul \
|
+__PERF_COUNTER_VER_MINOR__ * 100ul \
|
||||||
@ -891,6 +891,22 @@ extern void user_code_insert_to_systick_handler(void);
|
|||||||
*/
|
*/
|
||||||
extern void update_perf_counter(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