lesson 23, step 3

This commit is contained in:
Carlos
2015-08-18 10:31:28 +02:00
parent 92ff191c3d
commit de3d442569
18 changed files with 124 additions and 127 deletions

View File

@@ -3,21 +3,21 @@
#include "ports.h"
#include "../libc/function.h"
u32 tick = 0;
uint32_t tick = 0;
static void timer_callback(registers_t regs) {
tick++;
UNUSED(regs);
}
void init_timer(u32 freq) {
void init_timer(uint32_t freq) {
/* Install the function we just wrote */
register_interrupt_handler(IRQ0, timer_callback);
/* Get the PIT value: hardware clock at 1193180 Hz */
u32 divisor = 1193180 / freq;
u8 low = (u8)(divisor & 0xFF);
u8 high = (u8)( (divisor >> 8) & 0xFF);
uint32_t divisor = 1193180 / freq;
uint8_t low = (uint8_t)(divisor & 0xFF);
uint8_t high = (uint8_t)( (divisor >> 8) & 0xFF);
/* Send the command */
port_byte_out(0x43, 0x36); /* Command port */
port_byte_out(0x40, low);