23 lines
368 B
C++
23 lines
368 B
C++
SAMDTimer BuzzerTimer(TIMER_TC5);
|
|
|
|
bool attached = false;
|
|
|
|
void initBuzzer() {
|
|
pinMode(BUZZER_PIN, OUTPUT);
|
|
}
|
|
|
|
void buzzerISR() {
|
|
digitalWrite(BUZZER_PIN, !digitalRead(BUZZER_PIN));
|
|
}
|
|
|
|
void buzz() {
|
|
if (attached)
|
|
BuzzerTimer.enableTimer();
|
|
else
|
|
BuzzerTimer.attachInterrupt(BUZZER_FREQ *2, buzzerISR);
|
|
}
|
|
|
|
void noBuzz() {
|
|
BuzzerTimer.disableTimer();
|
|
}
|