Skip to content

Commit

Permalink
Use u16 for PIT_DIVIDER
Browse files Browse the repository at this point in the history
  • Loading branch information
vinc committed Oct 22, 2024
1 parent 0645094 commit 0bb94e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/sys/clk/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use x86_64::instructions::port::Port;
// During init we will change the divider to 1193 to have about 1.000 ms
// between ticks to improve time measurements accuracy.
const PIT_FREQUENCY: f64 = 3_579_545.0 / 3.0; // 1_193_181.666 Hz
const PIT_DIVIDER: usize = 1193;
const PIT_DIVIDER: u16 = 1193;
const PIT_INTERVAL: f64 = (PIT_DIVIDER as f64) / PIT_FREQUENCY;

static PIT_TICKS: AtomicUsize = AtomicUsize::new(0);
Expand Down Expand Up @@ -74,9 +74,9 @@ pub fn rtc_interrupt_handler() {

pub fn init() {
// PIT timmer
let divider = if PIT_DIVIDER < 65536 { PIT_DIVIDER } else { 0 };
let channel = 0;
set_pit_frequency(divider as u16, channel);
let divider = PIT_DIVIDER;
let channel = 0; // PIC
set_pit_frequency(divider, channel);
sys::idt::set_irq_handler(0, pit_interrupt_handler);

// RTC timmer
Expand Down
2 changes: 1 addition & 1 deletion src/sys/speaker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const SPEAKER_PORT: u16 = 0x61;
fn start_sound(freq: f64) {
debug!("speaker::start_sound({})", freq);
let divider = (clk::pit_frequency() / freq) as u16;
let channel = 2;
let channel = 2; // PC Speaker
clk::set_pit_frequency(divider, channel);

let mut speaker: Port<u8> = Port::new(SPEAKER_PORT);
Expand Down

0 comments on commit 0bb94e8

Please sign in to comment.