aboutsummaryrefslogtreecommitdiff
path: root/mirai.old/drivers/pit/pit.zig
blob: 93609b43c0e3055e0fe07a10583a3812865c7687 (plain)
1
2
3
4
5
6
7
8
9
10
11
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));
}