From: luozheng <1732036298@qq.com> Date: Sat, 2 Nov 2024 10:54:13 +0000 (+0800) Subject: 时间同步算法采用海思原本代码 X-Git-Tag: fd230_release_V1.3.102~29^2~83 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=a8029d0b6440944b3563dfba0ae43de0ba0514f1;p=mirrors%2FFD230.git 时间同步算法采用海思原本代码 --- diff --git a/code/sdk/drivers/chips/brandy/porting/liteos/riscv70/tick_timer.c b/code/sdk/drivers/chips/brandy/porting/liteos/riscv70/tick_timer.c index da092c196..9e9712c1e 100755 --- a/code/sdk/drivers/chips/brandy/porting/liteos/riscv70/tick_timer.c +++ b/code/sdk/drivers/chips/brandy/porting/liteos/riscv70/tick_timer.c @@ -143,19 +143,18 @@ uint64_t HalClockGetCycles(void) lock_int_save = LOS_IntLock(); #ifdef SUPPORT_RC_CALIBRATION - // if (g_pre_count == 0) { - // tick_count = (uapi_systick_get_count() * OS_SYS_MS_PER_SECOND) / CLOCK_32K_CALI_FREQ; - // g_pre_count = uapi_systick_get_count(); - // g_pre_msec = tick_count; - // } else { - // now_count = uapi_systick_get_count(); - // msec = (double)((now_count - g_pre_count) * OS_SYS_MS_PER_SECOND) / CLOCK_32K_CALI_FREQ; - // tick_count = g_pre_msec + msec; - - // g_pre_count = now_count; - // g_pre_msec = tick_count; - // } - tick_count = uapi_systick_get_ms(); + if (g_pre_count == 0) { + tick_count = (uapi_systick_get_count() * OS_SYS_MS_PER_SECOND) / CLOCK_32K_CALI_FREQ; + g_pre_count = uapi_systick_get_count(); + g_pre_msec = tick_count; + } else { + now_count = uapi_systick_get_count(); + msec = (double)((now_count - g_pre_count) * OS_SYS_MS_PER_SECOND) / CLOCK_32K_CALI_FREQ; + tick_count = g_pre_msec + msec; + + g_pre_count = now_count; + g_pre_msec = tick_count; + } #else tick_count = uapi_systick_get_ms(); #endif