获取系统运行时间—us计数值
uint32_t getCurrentMicros(void)
{
uint32_t m0 = HAL_GetTick();
__IO uint32_t u0 = SysTick->VAL;
uint32_t m1 = HAL_GetTick();
__IO uint32_t u1 = SysTick->VAL;
const uint32_t tms = SysTick->LOAD + 1;
if (m1 != m0) {
return (m1 * 1000 + ((tms - u1) * 1000) / tms);
} else {
return (m0 * 1000 + ((tms - u0) * 1000) / tms);
}
}
获取系统时间—ms计数
uint32_t getCurrentMillis(void)
{
return HAL_GetTick();
}
————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/xiaoyuanwuhui/article/details/142305816
|