Skip to content

Commit 3940d99

Browse files
committed
Tone library adaptation for ATmega16
1 parent ae28fa3 commit 3940d99

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

libraries/Tone/Tone.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <pins_arduino.h>
2828
#include "Tone.h"
2929

30-
#if defined(__AVR_ATmega8__)
30+
#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__)
3131
#define TCCR2A TCCR2
3232
#define TCCR2B TCCR2
3333
#define COM2A1 COM21
@@ -39,6 +39,14 @@
3939
#define TIMSK1 TIMSK
4040
#endif
4141

42+
#if defined(__AVR_ATmega16__)
43+
#define TCCR0A TCCR0
44+
#define TCCR0B TCCR0
45+
#define OCR0A OCR0
46+
#define TIMSK0 TIMSK
47+
#define OCIE0A OCIE0
48+
#endif
49+
4250
// timerx_toggle_count:
4351
// > 0 - duration specified
4452
// = 0 - stopped
@@ -83,6 +91,13 @@ const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2, 3, 4, 5, 1, 0 };
8391

8492
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2, 1 };
8593

94+
#elif defined(__AVR_ATmega16__)
95+
96+
#define AVAILABLE_TONE_PINS 3
97+
98+
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2, 1, 0 };
99+
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 31, 28, 11 };
100+
86101
#else
87102

88103
#define AVAILABLE_TONE_PINS 3

0 commit comments

Comments
 (0)