|
1 | 1 | //! Clock configuration |
2 | | -use crate::core::clint::MTIME; |
3 | 2 | use crate::time::Hertz; |
4 | | -use e310x::{Aonclk as AONCLK, Prci as PRCI}; |
| 3 | +use e310x::{Aonclk as AONCLK, Prci as PRCI, CLINT}; |
5 | 4 | use riscv::interrupt; |
6 | 5 | use riscv::register::mcycle; |
7 | 6 |
|
@@ -229,7 +228,7 @@ impl CoreClk { |
229 | 228 | }; |
230 | 229 |
|
231 | 230 | // Calculate the desired vco frequency |
232 | | - let target_vco_freq = pllout_freq * q; |
| 231 | + let target_vco_freq: u32 = pllout_freq * q; |
233 | 232 | assert!((VCO_MIN..=VCO_MAX).contains(&target_vco_freq)); |
234 | 233 |
|
235 | 234 | // Calculate PLL F ratio |
@@ -291,9 +290,9 @@ impl CoreClk { |
291 | 290 | // Need to wait 100 us |
292 | 291 | // RTC is running at 32kHz. |
293 | 292 | // So wait 4 ticks of RTC. |
294 | | - let mtime = MTIME; |
295 | | - let time = mtime.mtime() + 4; |
296 | | - while mtime.mtime() < time {} |
| 293 | + let mtime = CLINT::mtimer().mtime; |
| 294 | + let time = mtime.read() + 4; |
| 295 | + while mtime.read() < time {} |
297 | 296 | // Now it is safe to check for PLL Lock |
298 | 297 | while !prci.pllcfg().read().lock().bit_is_set() {} |
299 | 298 |
|
@@ -385,19 +384,19 @@ impl Clocks { |
385 | 384 |
|
386 | 385 | /// Measure the coreclk frequency by counting the number of aonclk ticks. |
387 | 386 | fn _measure_coreclk(&self, min_ticks: u64) -> Hertz { |
388 | | - let mtime = MTIME; |
| 387 | + let mtime = CLINT::mtimer().mtime; |
389 | 388 | interrupt::free(|| { |
390 | 389 | // Don't start measuring until we see an mtime tick |
391 | | - while mtime.mtime() == mtime.mtime() {} |
| 390 | + while mtime.read() == mtime.read() {} |
392 | 391 |
|
393 | 392 | let start_cycle = mcycle::read64(); |
394 | | - let start_time = mtime.mtime(); |
| 393 | + let start_time = mtime.read(); |
395 | 394 |
|
396 | 395 | // Wait for min_ticks to pass |
397 | | - while start_time + min_ticks > mtime.mtime() {} |
| 396 | + while start_time + min_ticks > mtime.read() {} |
398 | 397 |
|
399 | 398 | let end_cycle = mcycle::read64(); |
400 | | - let end_time = mtime.mtime(); |
| 399 | + let end_time = mtime.read(); |
401 | 400 |
|
402 | 401 | let delta_cycle: u64 = end_cycle - start_cycle; |
403 | 402 | let delta_time: u64 = end_time - start_time; |
|
0 commit comments