|
@@ -101,29 +101,29 @@ static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t
|
101
|
101
|
#ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform
|
102
|
102
|
|
103
|
103
|
// Interrupt handlers for Arduino
|
104
|
|
- #if defined(_useTimer1)
|
|
104
|
+ #ifdef _useTimer1
|
105
|
105
|
SIGNAL (TIMER1_COMPA_vect) { handle_interrupts(_timer1, &TCNT1, &OCR1A); }
|
106
|
106
|
#endif
|
107
|
107
|
|
108
|
|
- #if defined(_useTimer3)
|
|
108
|
+ #ifdef _useTimer3
|
109
|
109
|
SIGNAL (TIMER3_COMPA_vect) { handle_interrupts(_timer3, &TCNT3, &OCR3A); }
|
110
|
110
|
#endif
|
111
|
111
|
|
112
|
|
- #if defined(_useTimer4)
|
|
112
|
+ #ifdef _useTimer4
|
113
|
113
|
SIGNAL (TIMER4_COMPA_vect) { handle_interrupts(_timer4, &TCNT4, &OCR4A); }
|
114
|
114
|
#endif
|
115
|
115
|
|
116
|
|
- #if defined(_useTimer5)
|
|
116
|
+ #ifdef _useTimer5
|
117
|
117
|
SIGNAL (TIMER5_COMPA_vect) { handle_interrupts(_timer5, &TCNT5, &OCR5A); }
|
118
|
118
|
#endif
|
119
|
119
|
|
120
|
120
|
#else //!WIRING
|
121
|
121
|
|
122
|
122
|
// Interrupt handlers for Wiring
|
123
|
|
- #if defined(_useTimer1)
|
|
123
|
+ #ifdef _useTimer1
|
124
|
124
|
void Timer1Service() { handle_interrupts(_timer1, &TCNT1, &OCR1A); }
|
125
|
125
|
#endif
|
126
|
|
- #if defined(_useTimer3)
|
|
126
|
+ #ifdef _useTimer3
|
127
|
127
|
void Timer3Service() { handle_interrupts(_timer3, &TCNT3, &OCR3A); }
|
128
|
128
|
#endif
|
129
|
129
|
|
|
@@ -131,7 +131,7 @@ static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t
|
131
|
131
|
|
132
|
132
|
|
133
|
133
|
static void initISR(timer16_Sequence_t timer) {
|
134
|
|
- #if defined(_useTimer1)
|
|
134
|
+ #ifdef _useTimer1
|
135
|
135
|
if (timer == _timer1) {
|
136
|
136
|
TCCR1A = 0; // normal counting mode
|
137
|
137
|
TCCR1B = _BV(CS11); // set prescaler of 8
|
|
@@ -144,31 +144,31 @@ static void initISR(timer16_Sequence_t timer) {
|
144
|
144
|
TIFR1 |= _BV(OCF1A); // clear any pending interrupts;
|
145
|
145
|
TIMSK1 |= _BV(OCIE1A); // enable the output compare interrupt
|
146
|
146
|
#endif
|
147
|
|
- #if defined(WIRING)
|
|
147
|
+ #ifdef WIRING
|
148
|
148
|
timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service);
|
149
|
149
|
#endif
|
150
|
150
|
}
|
151
|
151
|
#endif
|
152
|
152
|
|
153
|
|
- #if defined(_useTimer3)
|
|
153
|
+ #ifdef _useTimer3
|
154
|
154
|
if (timer == _timer3) {
|
155
|
155
|
TCCR3A = 0; // normal counting mode
|
156
|
156
|
TCCR3B = _BV(CS31); // set prescaler of 8
|
157
|
157
|
TCNT3 = 0; // clear the timer count
|
158
|
|
- #if defined(__AVR_ATmega128__)
|
|
158
|
+ #ifdef __AVR_ATmega128__
|
159
|
159
|
TIFR |= _BV(OCF3A); // clear any pending interrupts;
|
160
|
160
|
ETIMSK |= _BV(OCIE3A); // enable the output compare interrupt
|
161
|
161
|
#else
|
162
|
162
|
TIFR3 = _BV(OCF3A); // clear any pending interrupts;
|
163
|
163
|
TIMSK3 = _BV(OCIE3A) ; // enable the output compare interrupt
|
164
|
164
|
#endif
|
165
|
|
- #if defined(WIRING)
|
|
165
|
+ #ifdef WIRING
|
166
|
166
|
timerAttach(TIMER3OUTCOMPAREA_INT, Timer3Service); // for Wiring platform only
|
167
|
167
|
#endif
|
168
|
168
|
}
|
169
|
169
|
#endif
|
170
|
170
|
|
171
|
|
- #if defined(_useTimer4)
|
|
171
|
+ #ifdef _useTimer4
|
172
|
172
|
if (timer == _timer4) {
|
173
|
173
|
TCCR4A = 0; // normal counting mode
|
174
|
174
|
TCCR4B = _BV(CS41); // set prescaler of 8
|
|
@@ -178,7 +178,7 @@ static void initISR(timer16_Sequence_t timer) {
|
178
|
178
|
}
|
179
|
179
|
#endif
|
180
|
180
|
|
181
|
|
- #if defined(_useTimer5)
|
|
181
|
+ #ifdef _useTimer5
|
182
|
182
|
if (timer == _timer5) {
|
183
|
183
|
TCCR5A = 0; // normal counting mode
|
184
|
184
|
TCCR5B = _BV(CS51); // set prescaler of 8
|
|
@@ -191,7 +191,7 @@ static void initISR(timer16_Sequence_t timer) {
|
191
|
191
|
|
192
|
192
|
static void finISR(timer16_Sequence_t timer) {
|
193
|
193
|
// Disable use of the given timer
|
194
|
|
- #if defined(WIRING)
|
|
194
|
+ #ifdef WIRING
|
195
|
195
|
if (timer == _timer1) {
|
196
|
196
|
#if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
|
197
|
197
|
TIMSK1
|