From 50f0d79e03aeaecc8c54effd57656e47839c44cc Mon Sep 17 00:00:00 2001 From: zogodo <742782908@qq.com> Date: Wed, 4 Dec 2019 21:48:12 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=B3=E7=A7=92OK1111=E5=B7=A6=E5=8F=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TC1/user_power.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/TC1/user_power.c b/TC1/user_power.c index d53edf2..e882cf9 100644 --- a/TC1/user_power.c +++ b/TC1/user_power.c @@ -73,7 +73,7 @@ char* GetPowerRecord(int idx) } float n_1s = 0; //功率中断次数 -uint64_t t_x = 0; //当前秒*1000,000 +uint64_t t_x = 0; //当前秒*1000,000,000 uint64_t past_ns = 0; //系统运行的纳秒数 uint64_t rest_x_ns = 0; //距离当前秒走过的纳秒数 uint64_t rest_y_ns = 0; //距离下一秒差的纳秒数 @@ -90,23 +90,23 @@ static void PowerIrqHandler(void* arg) past_ns = mico_nanosecond_clock_value(); if (t_x == 0) { - t_x = past_ns - past_ns % 1000000; + t_x = past_ns - past_ns % 1000000000; } rest_x_ns = past_ns - t_x; - if (rest_x_ns <= 1000000) + if (rest_x_ns <= 1000000000) { n_1s += 1; - rest_y_ns = t_x + 1000000 - past_ns; + rest_y_ns = t_x + 1000000000 - past_ns; } - else if (rest_x_ns > 1000000 && rest_x_ns < 2000000) + else if (rest_x_ns > 1000000000 && rest_x_ns < 2000000000) { - n_1s += (float)rest_y_ns / (rest_x_ns - 1000000 + rest_y_ns); - rest_y_ns = 2000000 - rest_x_ns; - t_x = past_ns - past_ns % 1000000; + n_1s += (float)rest_y_ns / (rest_x_ns - 1000000000 + rest_y_ns); + rest_y_ns = 2000000000 - rest_x_ns; + t_x = past_ns - past_ns % 1000000000; float power2 = 17.1 * n_1s; SetPowerRecord(&power_record, (int)power2); - n_1s = (float)(rest_x_ns - 1000000) / (rest_x_ns - 1000000 + rest_y_ns); + n_1s = (float)(rest_x_ns - 1000000000) / (rest_x_ns - 1000000000 + rest_y_ns); } else {