matos/drivers/pit.c

17 lines
370 B
C
Raw Normal View History

2018-07-20 15:41:58 +02:00
#include "pit.h"
#include "io.h"
#include "irq.h"
2018-07-20 15:41:58 +02:00
2018-11-08 22:08:27 +01:00
int pitSetup(unsigned int freq)
2018-07-20 15:41:58 +02:00
{
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);
2018-07-20 15:41:58 +02:00
return 0;
}