aboutsummaryrefslogtreecommitdiff
path: root/mirai/drivers/pit/pit.zig
diff options
context:
space:
mode:
Diffstat (limited to 'mirai/drivers/pit/pit.zig')
-rw-r--r--mirai/drivers/pit/pit.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/mirai/drivers/pit/pit.zig b/mirai/drivers/pit/pit.zig
new file mode 100644
index 0000000..93609b4
--- /dev/null
+++ b/mirai/drivers/pit/pit.zig
@@ -0,0 +1,12 @@
+//! PIT (Programmable Interval Timer) Driver
+
+const io = @import("../../asm/io.zig");
+const pit = @import("../../common/constants/pit.zig");
+
+pub fn init() void {
+ // 100 Hz for stable operation
+ const command = pit.SELECT_CHANNEL_0 | pit.ACCESS_LOHI | pit.MODE_RATE_GENERATOR;
+ io.out_byte(pit.COMMAND, command);
+ io.out_byte(pit.CHANNEL_0, @truncate(pit.DIVISOR_100HZ));
+ io.out_byte(pit.CHANNEL_0, @truncate(pit.DIVISOR_100HZ >> 8));
+}