mbr_asm/pit.c
Mathieu Maret 24cab443f2 Add pit driver
Still no IRQ handler called
2018-07-16 14:20:14 +02:00

15 lines
310 B
C

#include "pit.h"
#include "io.h"
int initPit(unsigned int freq)
{
unsigned int divisor = PIT_FREQ / freq;
if (divisor > 65535)
divisor = 0; // Used to represent 35536
outb(PIT_CMD, 0x34); // chan 0; low then high; mode 2
outb(PIT_CHAN_0, divisor & 0xFF);
outb(PIT_CHAN_0, divisor >> 8u);
return 0;
}