!385 fix: 修复cortex-m系列系统提供的timer在低频下时间不准的问题

Merge pull request !385 from zhushengle/timer
This commit is contained in:
openharmony_ci 2021-11-09 08:57:07 +00:00 committed by Gitee
commit 72928ca12e
10 changed files with 50 additions and 20 deletions

View File

@ -85,10 +85,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(UINT32 *period) WEAK UINT64 HalGetTickCycle(UINT32 *period)
{ {
UINT32 hwCycle; UINT32 hwCycle = 0;
UINT32 intSave = LOS_IntLock(); UINT32 intSave = LOS_IntLock();
UINT32 val = SysTick->VAL;
*period = SysTick->LOAD; *period = SysTick->LOAD;
hwCycle = *period - SysTick->VAL; if (val != 0) {
hwCycle = *period - val;
}
LOS_IntRestore(intSave); LOS_IntRestore(intSave);
return (UINT64)hwCycle; return (UINT64)hwCycle;
} }

View File

@ -84,10 +84,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(UINT32 *period) WEAK UINT64 HalGetTickCycle(UINT32 *period)
{ {
UINT32 hwCycle; UINT32 hwCycle = 0;
UINT32 intSave = LOS_IntLock(); UINT32 intSave = LOS_IntLock();
UINT32 val = SysTick->VAL;
*period = SysTick->LOAD; *period = SysTick->LOAD;
hwCycle = *period - SysTick->VAL; if (val != 0) {
hwCycle = *period - val;
}
LOS_IntRestore(intSave); LOS_IntRestore(intSave);
return (UINT64)hwCycle; return (UINT64)hwCycle;
} }

View File

@ -84,10 +84,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(UINT32 *period) WEAK UINT64 HalGetTickCycle(UINT32 *period)
{ {
UINT32 hwCycle; UINT32 hwCycle = 0
UINT32 intSave = LOS_IntLock(); UINT32 intSave = LOS_IntLock();
UINT32 val = SysTick->VAL;
*period = SysTick->LOAD; *period = SysTick->LOAD;
hwCycle = *period - SysTick->VAL; if (val != 0) {
hwCycle = *period - val;
}
LOS_IntRestore(intSave); LOS_IntRestore(intSave);
return (UINT64)hwCycle; return (UINT64)hwCycle;
} }

View File

@ -84,10 +84,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(UINT32 *period) WEAK UINT64 HalGetTickCycle(UINT32 *period)
{ {
UINT32 hwCycle; UINT32 hwCycle = 0;
UINT32 intSave = LOS_IntLock(); UINT32 intSave = LOS_IntLock();
UINT32 val = SysTick->VAL;
*period = SysTick->LOAD; *period = SysTick->LOAD;
hwCycle = *period - SysTick->VAL; if (val != 0) {
hwCycle = *period - val;
}
LOS_IntRestore(intSave); LOS_IntRestore(intSave);
return (UINT64)hwCycle; return (UINT64)hwCycle;
} }

View File

@ -84,10 +84,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(UINT32 *period) WEAK UINT64 HalGetTickCycle(UINT32 *period)
{ {
UINT32 hwCycle; UINT32 hwCycle = 0;
UINTPTR intSave = LOS_IntLock(); UINTPTR intSave = LOS_IntLock();
UINT32 val = SysTick->VAL;
*period = SysTick->LOAD; *period = SysTick->LOAD;
hwCycle = *period - SysTick->VAL; if (val != 0) {
hwCycle = *period - val;
}
LOS_IntRestore(intSave); LOS_IntRestore(intSave);
return (UINT64)hwCycle; return (UINT64)hwCycle;
} }

View File

@ -84,10 +84,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(UINT32 *period) WEAK UINT64 HalGetTickCycle(UINT32 *period)
{ {
UINT32 hwCycle; UINT32 hwCycle = 0;
UINTPTR intSave = LOS_IntLock(); UINTPTR intSave = LOS_IntLock();
UINT32 val = SysTick->VAL;
*period = SysTick->LOAD; *period = SysTick->LOAD;
hwCycle = *period - SysTick->VAL; if (val != 0) {
hwCycle = *period - val;
}
LOS_IntRestore(intSave); LOS_IntRestore(intSave);
return (UINT64)hwCycle; return (UINT64)hwCycle;
} }

View File

@ -85,10 +85,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(UINT32 *period) WEAK UINT64 HalGetTickCycle(UINT32 *period)
{ {
UINT32 hwCycle; UINT32 hwCycle = 0;
UINT32 intSave = LOS_IntLock(); UINT32 intSave = LOS_IntLock();
UINT32 val = SysTick->VAL;
*period = SysTick->LOAD; *period = SysTick->LOAD;
hwCycle = *period - SysTick->VAL; if (val != 0) {
hwCycle = *period - val;
}
LOS_IntRestore(intSave); LOS_IntRestore(intSave);
return (UINT64)hwCycle; return (UINT64)hwCycle;
} }

View File

@ -85,10 +85,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(UINT32 *period) WEAK UINT64 HalGetTickCycle(UINT32 *period)
{ {
UINT32 hwCycle; UINT32 hwCycle = 0;
UINT32 intSave = LOS_IntLock(); UINT32 intSave = LOS_IntLock();
UINT32 val = SysTick->VAL;
*period = SysTick->LOAD; *period = SysTick->LOAD;
hwCycle = *period - SysTick->VAL; if (val != 0) {
hwCycle = *period - val;
}
LOS_IntRestore(intSave); LOS_IntRestore(intSave);
return (UINT64)hwCycle; return (UINT64)hwCycle;
} }

View File

@ -84,10 +84,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(UINT32 *period) WEAK UINT64 HalGetTickCycle(UINT32 *period)
{ {
UINT32 hwCycle; UINT32 hwCycle = 0;
UINT32 intSave = LOS_IntLock(); UINT32 intSave = LOS_IntLock();
UINT32 val = SysTick->VAL;
*period = SysTick->LOAD; *period = SysTick->LOAD;
hwCycle = *period - SysTick->VAL; if (val != 0) {
hwCycle = *period - val;
}
LOS_IntRestore(intSave); LOS_IntRestore(intSave);
return (UINT64)hwCycle; return (UINT64)hwCycle;
} }

View File

@ -84,10 +84,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(UINT32 *period) WEAK UINT64 HalGetTickCycle(UINT32 *period)
{ {
UINT32 hwCycle; UINT32 hwCycle = 0;
UINT32 intSave = LOS_IntLock(); UINT32 intSave = LOS_IntLock();
UINT32 val = SysTick->VAL;
*period = SysTick->LOAD; *period = SysTick->LOAD;
hwCycle = *period - SysTick->VAL; if (val != 0) {
hwCycle = *period - val;
}
LOS_IntRestore(intSave); LOS_IntRestore(intSave);
return (UINT64)hwCycle; return (UINT64)hwCycle;
} }