blob: caa4b07c7195f1bfcd903f47321dbeb2a2bb1bc4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include <io/io.h>
#include <stdint.h>
#include <timer/timer.h>
void play_sound(u32 frequency)
{
u32 divided;
u8 tmp;
divided = 1193180 / frequency;
outb(0x43, 0xb6);
outb(0x42, (u8)(divided));
outb(0x42, (u8)(divided >> 8));
tmp = inb(0x61);
if (tmp != (tmp | 3)) {
outb(0x61, (u8)(tmp | 3));
}
}
static void shut_up()
{
u8 tmp = (u8)(inb(0x61) & 0xFC);
outb(0x61, tmp);
}
// Make a beep
void beep(u32 frequency, u32 ticks)
{
play_sound(frequency);
timer_wait((int)ticks);
shut_up();
}
|