aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino/Tone.cpp
diff options
context:
space:
mode:
authorJan <Jan.reucker@gmail.com>2015-04-13 20:36:28 +0200
committerJan <Jan.reucker@gmail.com>2015-04-13 20:36:28 +0200
commitd27eb7e1c1697715e8a800d4eca48ba1c1e6e867 (patch)
tree4831edaef59009d6991dd34a63bd7a45780fda84 /cores/arduino/Tone.cpp
parent331f5c832eb40da524e40dc08c6ff83aae79b954 (diff)
Fix for issue #292
Replaced direct register manipulation with calls to bitWrite(). Fixed TIMSK5 usage on Leonardo (as well as some other preprocessor statements).
Diffstat (limited to 'cores/arduino/Tone.cpp')
-rw-r--r--cores/arduino/Tone.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/cores/arduino/Tone.cpp b/cores/arduino/Tone.cpp
index eda8cbb..ad09573 100644
--- a/cores/arduino/Tone.cpp
+++ b/cores/arduino/Tone.cpp
@@ -390,7 +390,7 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
break;
#endif
-#if defined(TIMSK3)
+#if defined(OCR3A) && defined(TIMSK3) && defined(OCIE3A)
case 3:
OCR3A = ocr;
timer3_toggle_count = toggle_count;
@@ -398,7 +398,7 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
break;
#endif
-#if defined(TIMSK4)
+#if defined(OCR4A) && defined(TIMSK4) && defined(OCIE4A)
case 4:
OCR4A = ocr;
timer4_toggle_count = toggle_count;
@@ -455,21 +455,21 @@ void disableTimer(uint8_t _timer)
#endif
break;
-#if defined(TIMSK3)
+#if defined(TIMSK3) && defined(OCIE3A)
case 3:
- TIMSK3 &= ~(1 << OCIE3A);
+ bitWrite(TIMSK3, OCIE3A, 0);
break;
#endif
-#if defined(TIMSK4)
+#if defined(TIMSK4) && defined(OCIE4A)
case 4:
- TIMSK4 &= ~(1 << OCIE4A);
+ bitWrite(TIMSK4, OCIE4A, 0);
break;
#endif
-#if defined(TIMSK5)
+#if defined(TIMSK5) && defined(OCIE5A)
case 5:
- TIMSK5 &= ~(1 << OCIE5A);
+ bitWrite(TIMSK5, OCIE5A, 0);
break;
#endif
}