diff options
author | Marvin Borner | 2019-09-19 19:56:59 +0200 |
---|---|---|
committer | Marvin Borner | 2019-09-19 20:05:38 +0200 |
commit | 05e1fedcc9cd30d1a34a65e640da45e980b4f859 (patch) | |
tree | 9cfb7620907ac126f26cdfe9363cb73ed74ea179 /src/kernel/sound/frequency.c | |
parent | ffd82e18b5259fab477ad375a7af8550fac526d8 (diff) |
Moved source to kernel directory
Diffstat (limited to 'src/kernel/sound/frequency.c')
-rw-r--r-- | src/kernel/sound/frequency.c | 31 |
1 files changed, 31 insertions, 0 deletions
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 <stdint.h> +#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 |