matos/drivers/pit.c
Mathieu Maret 00d7004815 PIT/Serial irq refactoring
Serial IRQ still wip
2018-11-08 21:37:38 +01:00

17 lines
369 B
C

#include "pit.h"
#include "io.h"
#include "irq.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);
irqSetRoutine(IRQ_TIMER, timer_handler);
return 0;
}