Chapter3: power2/3/5 & sleep test worked on k210/qemu based on timer.
This commit is contained in:
parent
4590f233b5
commit
63aaa9d0a1
17 changed files with 183 additions and 82 deletions
13
os/src/timer.rs
Normal file
13
os/src/timer.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
use riscv::register::time;
|
||||
use crate::sbi::set_timer;
|
||||
use crate::config::CPU_FREQ;
|
||||
|
||||
const TICKS_PER_SEC: usize = 100;
|
||||
|
||||
pub fn get_time() -> usize {
|
||||
time::read()
|
||||
}
|
||||
|
||||
pub fn set_next_trigger() {
|
||||
set_timer(get_time() + CPU_FREQ / TICKS_PER_SEC);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue