Skip to content

Commit eb57c00

Browse files
Roy, Elizabethfacchinm
authored andcommitted
Keeping comments regarding commit history
1 parent 22185e1 commit eb57c00

File tree

1 file changed

+38
-32
lines changed

1 file changed

+38
-32
lines changed

cores/arduino/Tone.cpp

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/* Tone.cpp
22
3-
A Tone Generator Library for ATmega4809
3+
A Tone Generator Library
4+
5+
Written by Brett Hagman
46
57
This library is free software; you can redistribute it and/or
68
modify it under the terms of the GNU Lesser General Public
@@ -15,69 +17,73 @@
1517
You should have received a copy of the GNU Lesser General Public
1618
License along with this library; if not, write to the Free Software
1719
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18-
19-
*************************************************/
20+
21+
-------- ----------- -------- --------
22+
0001 B Hagman 09/08/02 Initial coding
23+
0002 B Hagman 09/08/18 Multiple pins
24+
0003 B Hagman 09/08/18 Moved initialization from constructor to begin()
25+
0004 B Hagman 09/09/26 Fixed problems with ATmega8
26+
0005 B Hagman 09/11/23 Scanned prescalars for best fit on 8 bit timers
27+
09/11/25 Changed pin toggle method to XOR
28+
09/11/25 Fixed timer0 from being excluded
29+
0006 D Mellis 09/12/29 Replaced objects with functions
30+
0007 M Sproul 10/08/29 Changed #ifdefs from cpu to register
31+
0008 S Kanemoto 12/06/22 Fixed for Leonardo by @maris_HY
32+
0009 J Reucker 15/04/10 Issue #292 Fixed problems with ATmega8 (thanks to Pete62)
33+
0010 jipp 15/04/13 added additional define check #2923
34+
0011 E Roy 13/02/18 ported to ATmega4809
35+
*************************************************/
2036

2137
#include <avr/interrupt.h>
2238
#include <avr/pgmspace.h>
2339
#include "Arduino.h"
2440
#include "pins_arduino.h"
2541

26-
#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__)
27-
#define TCCR2A TCCR2
28-
#define TCCR2B TCCR2
29-
#define COM2A1 COM21
30-
#define COM2A0 COM20
31-
#define OCR2A OCR2
32-
#define TIMSK2 TIMSK
33-
#define OCIE2A OCIE2
34-
#define TIMER2_COMPA_vect TIMER2_COMP_vect
35-
#define TIMSK1 TIMSK
36-
#endif
42+
#define AVAILABLE_TONE_PINS 1
3743

44+
#define USE_TIMERB1 // interferes with PWM on pin 3
45+
/*
46+
#define USE_TIMERB2 // interferes with PWM on pin 11
47+
#define USE_TIMERB0 // interferes with PWM on pin 6
48+
#define USE_TIMERA0 // interferes with PWM on pins 5,9,10 NOT RECOMMENDED
49+
*/
50+
51+
// Can't use TIMERB3 -- used for application time tracking
52+
// Using TIMERA0 NOT RECOMMENDED -- leave to last -- all other timers use its clock!
53+
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { TIMERB1 /*, TIMERB2, TIMERB0, TIMERA0 */ };
54+
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { NOT_A_PIN /*, NOT_A_PIN, NOT_A_PIN, NOT_A_PIN */ };
55+
56+
3857
// timerx_toggle_count:
3958
// > 0 - duration specified
4059
// = 0 - stopped
4160
// < 0 - infinitely (until stop() method called, or new play() called)
4261

43-
#if defined(TCA0)
62+
#if defined(USE_TIMERA0)
4463
volatile long timera0_toggle_count;
4564
volatile uint8_t *timera0_outtgl_reg;
4665
volatile uint8_t timera0_bit_mask;
4766
#endif
4867

49-
#if defined(TCB0)
68+
#if defined(USE_TIMERB0)
5069
volatile long timerb0_toggle_count;
5170
volatile uint8_t *timerb0_outtgl_reg;
5271
volatile uint8_t timerb0_bit_mask;
5372
#endif
5473

55-
#if defined(TCB1)
74+
#if defined(USE_TIMERB1)
75+
5676
volatile long timerb1_toggle_count;
5777
volatile uint8_t *timerb1_outtgl_reg;
5878
volatile uint8_t timerb1_bit_mask;
5979
#endif
6080

61-
#if defined(TCB2)
81+
#if defined(USE_TIMERB2)
6282
volatile long timerb2_toggle_count;
6383
volatile uint8_t *timerb2_outtgl_reg;
6484
volatile uint8_t timerb2_bit_mask;
6585
#endif
6686

67-
#define AVAILABLE_TONE_PINS 1
68-
#define USE_TIMERB1 // interferes with PWM on pin 3
69-
/*
70-
#define USE_TIMERB2 // interferes with PWM on pin 11
71-
#define USE_TIMERB0 // interferes with PWM on pin 6
72-
#define USE_TIMERA0 // interferes with PWM on pins 5,9,10
73-
*/
74-
75-
// Can't use TIMERB3 -- used for application time tracking
76-
// Leave TIMERA0 to last -- all other timers use its clock
77-
const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { TIMERB1 /*, TIMERB2, TIMERB0, TIMERA0 */ };
78-
static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { NOT_A_PIN /*, NOT_A_PIN, NOT_A_PIN, NOT_A_PIN */ };
79-
80-
8187
static int8_t toneBegin(uint8_t _pin)
8288
{
8389
int8_t _timer = -1;

0 commit comments

Comments
 (0)