add new function update_perf_counter()

This commit is contained in:
Gabriel Wang 2022-06-14 00:39:54 +01:00
parent ce1d99b088
commit 781389d0a7
2 changed files with 13 additions and 2 deletions

View File

@ -249,6 +249,14 @@ void __perf_os_patch_init(void)
{
}
/*!
* \brief update perf_counter as SystemCoreClock has been updated.
*/
void update_perf_counter(void)
{
s_nUSUnit = SystemCoreClock / 1000000ul;
s_nMSUnit = SystemCoreClock / 1000ul;
}
/*! \brief initialise cycle counter service
* \note - don't forget to tell the function whether the systick is already
@ -290,8 +298,7 @@ void init_cycle_counter(bool bIsSysTickOccupied)
//s_nSystemClockCounts = s_nCycleCounts;
s_nOffset = stop_cycle_counter();
s_nUSUnit = SystemCoreClock / 1000000ul;
s_nMSUnit = SystemCoreClock / 1000ul;
update_perf_counter();
s_lSystemClockCounts = 0; // reset system cycle counter
s_nSystemMS = 0; // reset system millisecond counter

View File

@ -582,6 +582,10 @@ extern void init_cycle_counter(bool bIsSysTickOccupied);
*/
extern void user_code_insert_to_systick_handler(void);
/*!
* \brief update perf_counter as SystemCoreClock has been updated.
*/
extern void update_perf_counter(void);
//#if defined(__clang__)
//# pragma clang diagnostic pop