From 0491a3f6af9e318b9e3774c34fe4923a67376829 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sun, 6 Oct 2024 16:20:14 -0400 Subject: better tick interface --- src/timer.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/timer.zig') diff --git a/src/timer.zig b/src/timer.zig index b30cfcf..00fd6ba 100644 --- a/src/timer.zig +++ b/src/timer.zig @@ -33,10 +33,15 @@ const driver = struct { self.lld.initialize(freq); } - pub fn ticks(self: driver) u32 { + pub fn count(self: driver) u32 { _ = self; return @atomicLoad(u32, &ticks_raw, .acquire); } + + pub fn delay(self: driver, ticks: u32) void { + const now = self.count(); + while (self.count() - now < ticks) {} + } }; pub const systick = driver { .lld = @ptrFromInt(0xE000E010) }; -- cgit v1.2.3