pit: fix pit_init and add freq argument

This commit is contained in:
2025-03-21 22:18:24 +03:00
parent eb098b77fe
commit a8ff36be52
4 changed files with 7 additions and 7 deletions
+4 -4
View File
@@ -26,12 +26,12 @@ Bit/s Usage
#define PIT_COMMAND_PORT 0x43
#define PIT_DATA_PORT 0x40
void pit_init() {
uint16_t frequency = 100;
void pit_init(int freq) {
int divisor = 1193180 / freq;
uint8_t command = 0x36;//00110110 see above to get the idea wtf is this number
outb(PIT_COMMAND_PORT, command);
outb(PIT_DATA_PORT, (uint8_t)(frequency & 0xFF));
outb(PIT_DATA_PORT, (uint8_t)((frequency >> 8) & 0xFF));
outb(PIT_DATA_PORT, divisor & 0xFF);
outb(PIT_DATA_PORT, divisor >> 8);
}