mirror of
https://github.com/GorgonMeducer/perf_counter.git
synced 2025-01-17 19:13:03 +08:00
add compenstation, PERF_CNT_DELAY_US_COMPENSATION, to delay_us
This commit is contained in:
parent
e14804538f
commit
e8f3f02300
@ -26,6 +26,10 @@
|
||||
# define PERF_CNT_COMPENSATION_THRESHOLD 16
|
||||
#endif
|
||||
|
||||
#ifndef PERF_CNT_DELAY_US_COMPENSATION
|
||||
# define PERF_CNT_DELAY_US_COMPENSATION 20
|
||||
#endif
|
||||
|
||||
/*============================ MACROS ========================================*/
|
||||
/* IO definitions (access restrictions to peripheral registers) */
|
||||
/**
|
||||
@ -297,6 +301,12 @@ void delay_us(int32_t iUs)
|
||||
{
|
||||
iUs *= SystemCoreClock / 1000000ul;
|
||||
|
||||
if (iUs <= PERF_CNT_DELAY_US_COMPENSATION) {
|
||||
return ;
|
||||
}
|
||||
|
||||
iUs -= PERF_CNT_DELAY_US_COMPENSATION;
|
||||
|
||||
start_cycle_counter();
|
||||
while(stop_cycle_counter() < iUs);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user