Skip to content

Commit 72b05ae

Browse files
committed
fix Tone lib for ATmega16
1 parent 108d421 commit 72b05ae

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

hardware/arduino/cores/arduino/Tone.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Version Modified By Date Comments
3636
#include "wiring.h"
3737
#include "pins_arduino.h"
3838

39-
#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__)
39+
#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega16__)
4040
#define TCCR2A TCCR2
4141
#define TCCR2B TCCR2
4242
#define COM2A1 COM21
@@ -48,6 +48,14 @@ Version Modified By Date Comments
4848
#define TIMSK1 TIMSK
4949
#endif
5050

51+
#if defined(__AVR_ATmega16__)
52+
#define TCCR0A TCCR0
53+
#define TCCR0B TCCR0
54+
#define OCR0A OCR0
55+
#define TIMSK0 TIMSK
56+
#define OCIE0A OCIE0
57+
#endif
58+
5159
// timerx_toggle_count:
5260
// > 0 - duration specified
5361
// = 0 - stopped
@@ -100,6 +108,13 @@ static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 25
100108
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1 */ };
101109
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ };
102110

111+
#elif defined(__AVR_ATmega16__)
112+
113+
#define AVAILABLE_TONE_PINS 3
114+
115+
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2, 1, 0 };
116+
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255, 255, 255 };
117+
103118
#else
104119

105120
#define AVAILABLE_TONE_PINS 1

0 commit comments

Comments
 (0)