fix timebase of delays in loader

should be tied to the system clock frequency
This commit is contained in:
bunnie 2025-11-01 20:09:12 +08:00
parent 05c9828106
commit 406e39a0d5
2 changed files with 3 additions and 2 deletions

View file

@ -54,4 +54,4 @@ pub const GUARD_MEMORY_BYTES: usize = 8 * crate::PAGE_SIZE; // 1 extra page for
pub const SWAPPER_PID: u8 = 2;
#[cfg(feature = "bao1x")]
pub const SYSTEM_CLOCK_FREQUENCY: u32 = 800_000_000;
pub const SYSTEM_CLOCK_FREQUENCY: u32 = bao1x_hal::board::DEFAULT_FCLK_FREQUENCY / 2;

View file

@ -36,7 +36,8 @@ pub fn delay(quantum: usize) {
use utralib::{CSR, utra};
// abuse the d11ctime timer to create some time-out like thing
let mut d11c = CSR::new(utra::d11ctime::HW_D11CTIME_BASE as *mut u32);
d11c.wfo(utra::d11ctime::CONTROL_COUNT, 333_333); // 1.0ms per interval
// 1.0ms per interval
d11c.wfo(utra::d11ctime::CONTROL_COUNT, crate::SYSTEM_CLOCK_FREQUENCY / 1000);
let mut polarity = d11c.rf(utra::d11ctime::HEARTBEAT_BEAT);
for _ in 0..quantum {
while polarity == d11c.rf(utra::d11ctime::HEARTBEAT_BEAT) {}