mirror of
https://github.com/GorgonMeducer/perf_counter.git
synced 2025-01-17 19:13:03 +08:00
update porting prototype
This commit is contained in:
parent
72e5eb9e1b
commit
142a2415b9
@ -86,7 +86,7 @@ int64_t perfc_port_get_system_timer_top(void);
|
||||
extern
|
||||
bool perfc_port_is_system_timer_ovf_pending(void);
|
||||
extern
|
||||
void perfc_port_init_system_timer(bool bTimerOccupied);
|
||||
bool perfc_port_init_system_timer(bool bTimerOccupied);
|
||||
extern
|
||||
int64_t perfc_port_get_system_timer_elapsed(void);
|
||||
extern
|
||||
@ -145,10 +145,11 @@ void update_perf_counter(void)
|
||||
}
|
||||
}
|
||||
|
||||
void init_cycle_counter(bool bIsSysTickOccupied)
|
||||
bool init_cycle_counter(bool bIsSysTickOccupied)
|
||||
{
|
||||
bool bResult = false;
|
||||
__IRQ_SAFE {
|
||||
perfc_port_init_system_timer(bIsSysTickOccupied); // use the longest period
|
||||
bResult = perfc_port_init_system_timer(bIsSysTickOccupied); // use the longest period
|
||||
perfc_port_clear_system_timer_ovf_pending();
|
||||
}
|
||||
|
||||
@ -158,6 +159,8 @@ void init_cycle_counter(bool bIsSysTickOccupied)
|
||||
s_lSystemUS = 0; // reset system microsecond counter
|
||||
|
||||
__perf_os_patch_init();
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
/*! \note this function should only be called when irq is disabled
|
||||
|
@ -900,8 +900,12 @@ extern int64_t __stop_task_cycle_counter(task_cycle_info_t *ptInfo);
|
||||
*
|
||||
* \param[in] bIsSysTickOccupied A boolean value which indicates whether SysTick
|
||||
* is already used by user application.
|
||||
*
|
||||
* \return false Failed to initialize the timer counter, as the timer is not
|
||||
* available or IO error.
|
||||
* \return true initialization is successful.
|
||||
*/
|
||||
extern void init_cycle_counter(bool bIsSysTickOccupied);
|
||||
extern bool init_cycle_counter(bool bIsSysTickOccupied);
|
||||
|
||||
|
||||
/*!
|
||||
|
@ -160,23 +160,27 @@ extern uint32_t SystemCoreClock;
|
||||
|
||||
#if !__PERFC_CFG_DISABLE_DEFAULT_SYSTICK_PORTING__
|
||||
__WEAK
|
||||
void perfc_port_init_system_timer(bool bTimerOccupied)
|
||||
bool perfc_port_init_system_timer(bool bTimerOccupied)
|
||||
{
|
||||
if (bTimerOccupied) {
|
||||
return ;
|
||||
}
|
||||
do {
|
||||
if (bTimerOccupied) {
|
||||
break;
|
||||
}
|
||||
|
||||
__IRQ_SAFE {
|
||||
SysTick->CTRL = 0;
|
||||
__IRQ_SAFE {
|
||||
SysTick->CTRL = 0;
|
||||
|
||||
SysTick->LOAD = SysTick_LOAD_RELOAD_Msk; /* set reload register */
|
||||
//NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
|
||||
SysTick_CTRL_TICKINT_Msk |
|
||||
SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
|
||||
//SCB->ICSR = SCB_ICSR_PENDSTCLR_Msk;
|
||||
}
|
||||
SysTick->LOAD = SysTick_LOAD_RELOAD_Msk; /* set reload register */
|
||||
//NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
|
||||
SysTick_CTRL_TICKINT_Msk |
|
||||
SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
|
||||
//SCB->ICSR = SCB_ICSR_PENDSTCLR_Msk;
|
||||
}
|
||||
} while(0);
|
||||
|
||||
retun true;
|
||||
}
|
||||
|
||||
__WEAK
|
||||
|
@ -859,7 +859,7 @@ int64_t perfc_port_get_system_timer_top(void);
|
||||
extern
|
||||
bool perfc_port_is_system_timer_ovf_pending(void);
|
||||
extern
|
||||
void perfc_port_init_system_timer(bool bTimerOccupied);
|
||||
bool perfc_port_init_system_timer(bool bTimerOccupied);
|
||||
extern
|
||||
int64_t perfc_port_get_system_timer_elapsed(void);
|
||||
extern
|
||||
@ -878,10 +878,14 @@ void perfc_port_clear_system_timer_counter(void);
|
||||
|
||||
#if __PERFC_USE_PMU_PORTING__
|
||||
|
||||
void perfc_port_init_system_timer(bool bIsTimeOccupied)
|
||||
bool perfc_port_init_system_timer(bool bIsTimeOccupied)
|
||||
{
|
||||
UNUSED_PARAM(bIsTimeOccupied);
|
||||
|
||||
if (!(PMU->TYPE & PMU_TYPE_CYCCNT_PRESENT_Msk)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
__IRQ_SAFE {
|
||||
ARM_PMU_Disable();
|
||||
|
||||
@ -892,6 +896,8 @@ void perfc_port_init_system_timer(bool bIsTimeOccupied)
|
||||
ARM_PMU_CNTR_Enable(PMU_CNTENSET_CCNTR_ENABLE_Msk);
|
||||
ARM_PMU_Enable();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t perfc_port_get_system_timer_freq(void)
|
||||
|
@ -52,7 +52,7 @@ int64_t perfc_port_get_system_timer_top(void);
|
||||
extern
|
||||
bool perfc_port_is_system_timer_ovf_pending(void);
|
||||
extern
|
||||
void perfc_port_init_system_timer(bool bTimerOccupied);
|
||||
bool perfc_port_init_system_timer(bool bTimerOccupied);
|
||||
extern
|
||||
int64_t perfc_port_get_system_timer_elapsed(void);
|
||||
extern
|
||||
@ -67,20 +67,25 @@ void perfc_port_clear_system_timer_counter(void);
|
||||
|
||||
#if __PERFC_USE_USER_CUSTOM_PORTING__
|
||||
|
||||
void perfc_port_init_system_timer(bool bIsTimeOccupied)
|
||||
bool perfc_port_init_system_timer(bool bIsTimeOccupied)
|
||||
{
|
||||
if (bIsTimeOccupied) {
|
||||
return ;
|
||||
}
|
||||
bool bResult = true;
|
||||
do {
|
||||
if (bIsTimeOccupied) {
|
||||
break;
|
||||
}
|
||||
|
||||
__IRQ_SAFE {
|
||||
/* Configure the system timer count with the longest possible period
|
||||
* clear counter
|
||||
* Clear overflow pending flag
|
||||
* Enable interrupt if required
|
||||
* start counting
|
||||
*/
|
||||
}
|
||||
__IRQ_SAFE {
|
||||
/* Configure the system timer count with the longest possible period
|
||||
* clear counter
|
||||
* Clear overflow pending flag
|
||||
* Enable interrupt if required
|
||||
* start counting
|
||||
*/
|
||||
}
|
||||
} while(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t perfc_port_get_system_timer_freq(void)
|
||||
|
Loading…
x
Reference in New Issue
Block a user