Update sys_time unit to ms && Update clock freq of K210.

This commit is contained in:
Yifan Wu 2020-12-29 21:49:51 +08:00
parent 5985986249
commit 45fb4113d1
4 changed files with 13 additions and 8 deletions

View file

@ -1,13 +1,18 @@
use riscv::register::time;
use crate::sbi::set_timer;
use crate::config::CPU_FREQ;
use crate::config::CLOCK_FREQ;
const TICKS_PER_SEC: usize = 100;
const MSEC_PER_SEC: usize = 1000;
pub fn get_time() -> usize {
time::read()
}
pub fn get_time_ms() -> usize {
time::read() / (CLOCK_FREQ / MSEC_PER_SEC)
}
pub fn set_next_trigger() {
set_timer(get_time() + CPU_FREQ / TICKS_PER_SEC);
}
set_timer(get_time() + CLOCK_FREQ / TICKS_PER_SEC);
}