Added pcspk.h for PC Speaker and notes.h that contains notes and their frequencies

This commit is contained in:
2024-05-19 17:05:53 +02:00
parent 347bf17586
commit dcbf24beae
4 changed files with 170 additions and 3 deletions
+32
View File
@@ -0,0 +1,32 @@
#ifndef PCSPK_H
#define PCSPK_H
#include <stdint.h>
#include <sound/notes.h>
#include <interrupt/pit.h>
#include <ports/io.h>
#include <time.h>
#define PC_SPEAKER 0x61
void enableSpeaker() {
uint8_t temp = inb(PC_SPEAKER);
outb(PC_SPEAKER, temp | 0x03); // Set first 2 bits
}
void disableSpeaker() {
uint8_t temp = inb(PC_SPEAKER);
outb(PC_SPEAKER, temp & 0xfc); // Set first 2 bits
}
void playNote(note_t note, uint32_t ms) {
setPitPhase(2, 3, note);
sleep(ms);
}
void rest(uint32_t ms) {
setPitPhase(2, 3, 30000); // Unhearable noise
sleep(ms);
}
#endif