mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-20 17:44:20 +08:00
🐞 fix(ktime): fix wrong boottime
因为tick从中断到设置中间的时延特别大,因此暂不采用tick做基准时间,直接取gtime的cnt做基准时间
This commit is contained in:
@@ -13,6 +13,10 @@
|
||||
#include <gtimer.h>
|
||||
#include <cpuport.h>
|
||||
|
||||
#ifdef RT_USING_KTIME
|
||||
#include <ktime.h>
|
||||
#endif
|
||||
|
||||
#define EL1_PHY_TIMER_IRQ_NUM 30
|
||||
|
||||
static volatile rt_uint64_t timer_step;
|
||||
@@ -38,6 +42,9 @@ void rt_hw_gtimer_local_enable(void)
|
||||
rt_hw_gtimer_disable();
|
||||
rt_hw_set_gtimer_val(timer_step);
|
||||
rt_hw_interrupt_umask(EL1_PHY_TIMER_IRQ_NUM);
|
||||
#ifdef RT_USING_KTIME
|
||||
rt_ktime_cputimer_init();
|
||||
#endif
|
||||
rt_hw_gtimer_enable();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
#include <encoding.h>
|
||||
#include "sbi.h"
|
||||
|
||||
#ifdef RT_USING_KTIME
|
||||
#include <ktime.h>
|
||||
#endif
|
||||
|
||||
static volatile uint64_t time_elapsed = 0;
|
||||
static volatile unsigned long tick_cycles = 0;
|
||||
|
||||
@@ -49,6 +53,9 @@ int rt_hw_tick_init(void)
|
||||
/* Set timer */
|
||||
sbi_set_timer(get_ticks() + tick_cycles);
|
||||
|
||||
#ifdef RT_USING_KTIME
|
||||
rt_ktime_cputimer_init();
|
||||
#endif
|
||||
/* Enable the Supervisor-Timer bit in SIE */
|
||||
set_csr(sie, SIP_STIP);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user