From 6110d57c164cf4186e9d8c5f50eef0f3c0a08041 Mon Sep 17 00:00:00 2001
From: Scott Lahteine <sourcetree@thinkyhead.com>
Date: Tue, 2 Aug 2016 19:13:04 -0700
Subject: [PATCH] Prevent the 'tone(f,d)' function from being interrupted

---
 Marlin/buzzer.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Marlin/buzzer.h b/Marlin/buzzer.h
index 4548acfaa3..199d64e419 100644
--- a/Marlin/buzzer.h
+++ b/Marlin/buzzer.h
@@ -23,6 +23,7 @@
 #ifndef __BUZZER_H__
 #define __BUZZER_H__
 
+#include "types.h"
 #include "fastio.h"
 #include "circularqueue.h"
 #include "temperature.h"
@@ -127,7 +128,9 @@ class Buzzer {
 
         if (this->state.tone.frequency > 0) {
           #if ENABLED(SPEAKER)
+            CRITICAL_SECTION_START;
             ::tone(BEEPER_PIN, this->state.tone.frequency, this->state.tone.duration);
+            CRITICAL_SECTION_END;
           #else
             this->on();
           #endif
-- 
GitLab