From 05e1fedcc9cd30d1a34a65e640da45e980b4f859 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 19 Sep 2019 19:56:59 +0200 Subject: Moved source to kernel directory --- src/kernel/sound/frequency.c | 31 +++++++++++++++++++++++++++++++ src/kernel/sound/sound.h | 6 ++++++ 2 files changed, 37 insertions(+) create mode 100644 src/kernel/sound/frequency.c create mode 100644 src/kernel/sound/sound.h (limited to 'src/kernel/sound') diff --git a/src/kernel/sound/frequency.c b/src/kernel/sound/frequency.c new file mode 100644 index 0000000..6d02690 --- /dev/null +++ b/src/kernel/sound/frequency.c @@ -0,0 +1,31 @@ +#include +#include "../io/io.h" +#include "../timer/timer.h" + +static void play_sound(uint32_t frequency) { + uint32_t divided; + uint8_t tmp; + + divided = 1193180 / frequency; + send(0x43, 0xb6); + send(0x42, (uint8_t) (divided)); + send(0x42, (uint8_t) (divided >> 8)); + + tmp = receive(0x61); + if (tmp != (tmp | 3)) { + send(0x61, tmp | 3); + } +} + +static void shut_up() { + uint8_t tmp = receive(0x61) & 0xFC; + + send(0x61, tmp); +} + +//Make a beep +void beep(uint32_t frequency, uint32_t ticks) { + play_sound(frequency); + timer_wait(ticks); + shut_up(); +} \ No newline at end of file diff --git a/src/kernel/sound/sound.h b/src/kernel/sound/sound.h new file mode 100644 index 0000000..baf70b2 --- /dev/null +++ b/src/kernel/sound/sound.h @@ -0,0 +1,6 @@ +#ifndef MELVIX_SOUND_H +#define MELVIX_SOUND_H + +void beep(uint32_t frequency, uint32_t ticks); + +#endif -- cgit v1.2.3