aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/include/pcspkr.h3
-rw-r--r--drivers/pcspkr.c19
2 files changed, 22 insertions, 0 deletions
diff --git a/drivers/include/pcspkr.h b/drivers/include/pcspkr.h
new file mode 100644
index 0000000..84e640f
--- /dev/null
+++ b/drivers/include/pcspkr.h
@@ -0,0 +1,3 @@
+#include <stdint.h>
+
+void pcspkr_play(uint32_t freq);
diff --git a/drivers/pcspkr.c b/drivers/pcspkr.c
new file mode 100644
index 0000000..33c0540
--- /dev/null
+++ b/drivers/pcspkr.c
@@ -0,0 +1,19 @@
+#include <stdint.h>
+#include "io.h"
+#include "pcspkr.h"
+
+void pcspkr_play(uint32_t freq)
+{
+ uint32_t div;
+ uint8_t tmp;
+
+ div = 1193180 / freq;
+ outb(0x43, 0xb6);
+ outb(0x42, (uint8_t)(div));
+ outb(0x42, (uint8_t)(div >> 8));
+
+ tmp = inb(0x61);
+ if (tmp != (tmp | 3)) {
+ outb(0x61, tmp | 3);
+ }
+}