mirror of
https://github.com/GorgonMeducer/perf_counter.git
synced 2025-01-31 19:33:04 +08:00
improve the support for EventRecorder
This commit is contained in:
parent
f894704e50
commit
ee560a054d
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* Copyright 2022 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) *
|
||||
* Copyright 2024 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) *
|
||||
* *
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); *
|
||||
* you may not use this file except in compliance with the License. *
|
||||
@ -180,8 +180,13 @@ volatile static int32_t s_nSystemUS = 0;
|
||||
|
||||
volatile static int64_t s_lSystemClockCounts = 0;
|
||||
|
||||
PERF_NOINIT
|
||||
volatile static int64_t s_lNoInitTimestamp;
|
||||
|
||||
|
||||
/*============================ PROTOTYPES ====================================*/
|
||||
static int64_t get_no_init_timestamp(void);
|
||||
|
||||
/*============================ IMPLEMENTATION ================================*/
|
||||
/*============================ INCLUDES ======================================*/
|
||||
|
||||
@ -210,6 +215,7 @@ void user_code_insert_to_systick_handler(void)
|
||||
{
|
||||
uint32_t wLoad = SysTick->LOAD + 1;
|
||||
s_lSystemClockCounts += wLoad;
|
||||
s_lNoInitTimestamp += wLoad;
|
||||
|
||||
// update system ms counter
|
||||
do {
|
||||
@ -313,7 +319,7 @@ void before_cycle_counter_reconfiguration(void)
|
||||
|
||||
}
|
||||
s_lSystemClockCounts = get_system_ticks(); /* get the final cycle counter value */
|
||||
|
||||
s_lNoInitTimestamp = get_no_init_timestamp();
|
||||
SysTick->LOAD = 0UL;
|
||||
SysTick->VAL = 0UL; /* clear the Current Value Register */
|
||||
}
|
||||
@ -390,6 +396,17 @@ int64_t get_system_ticks(void)
|
||||
return lTemp;
|
||||
}
|
||||
|
||||
static int64_t get_no_init_timestamp(void)
|
||||
{
|
||||
int64_t lTemp = 0;
|
||||
|
||||
__IRQ_SAFE {
|
||||
lTemp = check_systick() + s_lNoInitTimestamp;
|
||||
}
|
||||
|
||||
return lTemp;
|
||||
}
|
||||
|
||||
/*! \note the prototype of this clock() is different from the one defined in
|
||||
*! time.h. As clock_t is usually defined as unsigned int, it is
|
||||
*! not big enough in Cortex-M system to hold a time-stamp. clock()
|
||||
@ -497,6 +514,7 @@ bool __perfc_is_time_out(int64_t lPeriod, int64_t *plTimestamp, bool bAutoReload
|
||||
uint32_t EventRecorderTimerSetup (void)
|
||||
{
|
||||
/* doing nothing at all */
|
||||
s_lNoInitTimestamp = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -511,7 +529,7 @@ uint32_t EventRecorderTimerGetFreq (void)
|
||||
/// \return timer count (32-bit)
|
||||
uint32_t EventRecorderTimerGetCount (void)
|
||||
{
|
||||
return get_system_ticks();
|
||||
return get_no_init_timestamp();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* Copyright 2022 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) *
|
||||
* Copyright 2024 Gorgon Meducer (Email:embedded_zhuoran@hotmail.com) *
|
||||
* *
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); *
|
||||
* you may not use this file except in compliance with the License. *
|
||||
@ -35,9 +35,9 @@ extern "C" {
|
||||
*/
|
||||
#define __PERF_COUNTER_VER_MAJOR__ 2
|
||||
#define __PERF_COUNTER_VER_MINOR__ 2
|
||||
#define __PERF_COUNTER_VER_REVISE__ 4
|
||||
#define __PERF_COUNTER_VER_REVISE__ 5
|
||||
|
||||
#define __PERF_COUNTER_VER_STR__ ""
|
||||
#define __PERF_COUNTER_VER_STR__ "dev"
|
||||
|
||||
#define __PER_COUNTER_VER__ (__PERF_COUNTER_VER_MAJOR__ * 10000ul \
|
||||
+__PERF_COUNTER_VER_MINOR__ * 100ul \
|
||||
@ -134,6 +134,25 @@ extern "C" {
|
||||
# define UNUSED_PARAM(__VAR) (void)(__VAR)
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \brief an attribute for static variables that no initialisation is required
|
||||
* in the C startup process.
|
||||
*/
|
||||
#ifndef PERF_NOINIT
|
||||
# if defined(__IS_COMPILER_ARM_COMPILER_5__)
|
||||
# define PERF_NOINIT __attribute__(( section( ".bss.noinit"),zero_init))
|
||||
# elif defined(__IS_COMPILER_ARM_COMPILER_6__)
|
||||
# define PERF_NOINIT __attribute__(( section( ".bss.noinit")))
|
||||
# elif defined(__IS_COMPILER_IAR__)
|
||||
# define PERF_NOINIT __no_init
|
||||
# elif (defined(__IS_COMPILER_GCC__) || defined(__IS_COMPILER_LLVM__)) && !defined(__APPLE__)
|
||||
# define PERF_NOINIT __attribute__(( section( ".bss.noinit")))
|
||||
# else
|
||||
# define PERF_NOINIT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#undef __CONNECT2
|
||||
#undef __CONNECT3
|
||||
#undef __CONNECT4
|
||||
|
Loading…
x
Reference in New Issue
Block a user