From a8029d0b6440944b3563dfba0ae43de0ba0514f1 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Sat, 2 Nov 2024 18:54:13 +0800 Subject: [PATCH] =?utf8?q?=E6=97=B6=E9=97=B4=E5=90=8C=E6=AD=A5=E7=AE=97?= =?utf8?q?=E6=B3=95=E9=87=87=E7=94=A8=E6=B5=B7=E6=80=9D=E5=8E=9F=E6=9C=AC?= =?utf8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../porting/liteos/riscv70/tick_timer.c | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) 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 -- 2.17.1