-
Notifications
You must be signed in to change notification settings - Fork 1
/
timer128.c
689 lines (604 loc) · 17.3 KB
/
timer128.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
/*! \file timer128.c \brief System Timer function library for Mega128. */
//*****************************************************************************
//
// File Name : 'timer128.c'
// Title : System Timer function library for Mega128
// Author : Pascal Stang - Copyright (C) 2000-2003
// Created : 11/22/2000
// Revised : 02/24/2003
// Version : 1.2
// Target MCU : Atmel AVR Series
// Editor Tabs : 4
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//
//*****************************************************************************
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/sleep.h>
#include "global.h"
#include "timer128.h"
// Program ROM constants
// the prescale division values stored in order of timer control register index
// STOP, CLK, CLK/8, CLK/64, CLK/256, CLK/1024
unsigned const short __attribute__ ((progmem)) TimerPrescaleFactor[] = {0,1,8,64,256,1024};
// the prescale division values stored in order of timer control register index
// STOP, CLK, CLK/8, CLK/32, CLK/64, CLK/128, CLK/256, CLK/1024
unsigned const short __attribute__ ((progmem)) TimerRTCPrescaleFactor[] = {0,1,8,32,64,128,256,1024};
// Global variables
// time registers
volatile unsigned long TimerPauseReg;
volatile unsigned long Timer0Reg0;
volatile unsigned long Timer0Reg1;
volatile unsigned long Timer2Reg0;
volatile unsigned long Timer2Reg1;
typedef void (*voidFuncPtr)(void);
volatile static voidFuncPtr TimerIntFunc[TIMER_NUM_INTERRUPTS];
// delay for a minimum of <us> microseconds
// the time resolution is dependent on the time the loop takes
// e.g. with 4Mhz and 5 cycles per loop, the resolution is 1.25 us
void delay_us(unsigned short time_us)
{
unsigned short delay_loops;
register unsigned short i;
delay_loops = (time_us+3)/5*CYCLES_PER_US; // +3 for rounding up (dirty)
// one loop takes 5 cpu cycles
for (i=0; i < delay_loops; i++) {};
}
/*
void delay_ms(unsigned char time_ms)
{
unsigned short delay_count = F_CPU / 4000;
unsigned short cnt;
asm volatile ("\n"
"L_dl1%=:\n\t"
"mov %A0, %A2\n\t"
"mov %B0, %B2\n"
"L_dl2%=:\n\t"
"sbiw %A0, 1\n\t"
"brne L_dl2%=\n\t"
"dec %1\n\t" "brne L_dl1%=\n\t":"=&w" (cnt)
:"r"(time_ms), "r"((unsigned short) (delay_count))
);
}
*/
void timerInit(void)
{
u08 intNum;
// detach all user functions from interrupts
for(intNum=0; intNum<TIMER_NUM_INTERRUPTS; intNum++)
timerDetach(intNum);
// initialize all timers
timer0Init();
timer1Init();
timer2Init();
timer3Init();
// enable interrupts
sei();
}
void timer0Init()
{
// initialize timer 0
timer0SetPrescaler( TIMER0PRESCALE ); // set prescaler
outb(TCNT0, 0); // reset TCNT0
sbi(TIMSK, TOIE0); // enable TCNT0 overflow interrupt
timer0ClearOverflowCount(); // initialize time registers
}
void timer1Init(void)
{
// initialize timer 1
timer1SetPrescaler( TIMER1PRESCALE ); // set prescaler
outb(TCNT1H, 0); // reset TCNT1
outb(TCNT1L, 0);
sbi(TIMSK, TOIE1); // enable TCNT1 overflow
}
void timer2Init(void)
{
// initialize timer 2
timer2SetPrescaler( TIMER2PRESCALE ); // set prescaler
outb(TCNT2, 0); // reset TCNT2
sbi(TIMSK, TOIE2); // enable TCNT2 overflow
timer2ClearOverflowCount(); // initialize time registers
}
void timer3Init(void)
{
// initialize timer 3
timer3SetPrescaler( TIMER3PRESCALE ); // set prescaler
outb(TCNT3H, 0); // reset TCNT3
outb(TCNT3L, 0);
sbi(ETIMSK, TOIE3); // enable TCNT3 overflow
}
void timer0SetPrescaler(u08 prescale)
{
// set prescaler on timer 0
outb(TCCR0, (inb(TCCR0) & ~TIMER_PRESCALE_MASK) | prescale);
}
void timer1SetPrescaler(u08 prescale)
{
// set prescaler on timer 1
outb(TCCR1B, (inb(TCCR1B) & ~TIMER_PRESCALE_MASK) | prescale);
}
void timer2SetPrescaler(u08 prescale)
{
// set prescaler on timer 2
outb(TCCR2, (inb(TCCR2) & ~TIMER_PRESCALE_MASK) | prescale);
}
void timer3SetPrescaler(u08 prescale)
{
// set prescaler on timer 2
outb(TCCR3B, (inb(TCCR3B) & ~TIMER_PRESCALE_MASK) | prescale);
}
u16 timer0GetPrescaler(void)
{
// get the current prescaler setting
return (pgm_read_word(TimerPrescaleFactor+(inb(TCCR0) & TIMER_PRESCALE_MASK)));
}
u16 timer1GetPrescaler(void)
{
// get the current prescaler setting
return (pgm_read_word(TimerPrescaleFactor+(inb(TCCR1B) & TIMER_PRESCALE_MASK)));
}
u16 timer2GetPrescaler(void)
{
// get the current prescaler setting
return (pgm_read_word(TimerPrescaleFactor+(inb(TCCR2) & TIMER_PRESCALE_MASK)));
}
u16 timer3GetPrescaler(void)
{
// get the current prescaler setting
return (pgm_read_word(TimerPrescaleFactor+(inb(TCCR3B) & TIMER_PRESCALE_MASK)));
}
void timerAttach(u08 interruptNum, void (*userFunc)(void) )
{
// make sure the interrupt number is within bounds
if(interruptNum < TIMER_NUM_INTERRUPTS)
{
// set the interrupt function to run
// the supplied user's function
TimerIntFunc[interruptNum] = userFunc;
}
}
void timerDetach(u08 interruptNum)
{
// make sure the interrupt number is within bounds
if(interruptNum < TIMER_NUM_INTERRUPTS)
{
// set the interrupt function to run nothing
TimerIntFunc[interruptNum] = 0;
}
}
void timerPause(unsigned short pause_ms)
{
// pauses for exactly <pause_ms> number of milliseconds
u08 timerThres;
u32 ticRateHz;
u32 pause;
// capture current pause timer value
timerThres = inb(TCNT2);
// reset pause timer overflow count
TimerPauseReg = 0;
// calculate delay for [pause_ms] milliseconds
// prescaler division = 1<<(pgm_read_byte(TimerPrescaleFactor+inb(TCCR2)))
ticRateHz = F_CPU/timer2GetPrescaler();
// precision management
// prevent overflow and precision underflow
// -could add more conditions to improve accuracy
if( ((ticRateHz < 429497) && (pause_ms <= 10000)) )
pause = (pause_ms*ticRateHz)/1000;
else
pause = pause_ms*(ticRateHz/1000);
// loop until time expires
while( ((TimerPauseReg<<8) | inb(TCNT2)) < (pause+timerThres) )
{
if( TimerPauseReg < (pause>>8));
{
// save power by idling the processor
set_sleep_mode(SLEEP_MODE_IDLE);
sleep_mode();
}
}
}
void timer0ClearOverflowCount(void)
{
// clear the timer overflow counter registers
Timer0Reg0 = 0; // initialize time registers
Timer0Reg1 = 0; // initialize time registers
}
long timer0GetOverflowCount(void)
{
// return the current timer overflow count
// (this is since the last timer0ClearOverflowCount() command was called)
return Timer0Reg0;
}
void timer2ClearOverflowCount(void)
{
// clear the timer overflow counter registers
Timer2Reg0 = 0; // initialize time registers
Timer2Reg1 = 0; // initialize time registers
}
long timer2GetOverflowCount(void)
{
// return the current timer overflow count
// (this is since the last timer2ClearOverflowCount() command was called)
return Timer2Reg0;
}
void timer1PWMInit(u08 bitRes)
{
// configures timer1 for use with PWM output
// on pins OC1A, OC1B, and OC1C
// enable Timer1 as 8,9,10bit PWM
if(bitRes == 9)
{ // 9bit mode
sbi(TCCR1A,WGMA1);
cbi(TCCR1A,WGMA0);
}
else if( bitRes == 10 )
{ // 10bit mode
sbi(TCCR1A,WGMA1);
sbi(TCCR1A,WGMA0);
}
else
{ // default 8bit mode
cbi(TCCR1A,WGMA1);
sbi(TCCR1A,WGMA0);
}
// set clear-timer-on-compare-match
//cbi(TCCR1B,CTC1);
// clear output compare value A
outb(OCR1AH, 0);
outb(OCR1AL, 0);
// clear output compare value B
outb(OCR1BH, 0);
outb(OCR1BL, 0);
// clear output compare value C
outb(OCR1CH, 0);
outb(OCR1CL, 0);
}
void timer1PWMInitICR(u16 topcount)
{
// set PWM mode with ICR top-count
cbi(TCCR1A,WGM10);
sbi(TCCR1A,WGM11);
sbi(TCCR1B,WGM12);
sbi(TCCR1B,WGM13);
// set top count value
ICR1H = (u08)(topcount>>8);
ICR1L = (u08)topcount;
// clear output compare value A
outb(OCR1AH, 0);
outb(OCR1AL, 0);
// clear output compare value B
outb(OCR1BH, 0);
outb(OCR1BL, 0);
// clear output compare value C
outb(OCR1CH, 0);
outb(OCR1CL, 0);
}
void timer1PWMOff(void)
{
// turn off PWM on Timer1
cbi(TCCR1A,WGMA1);
cbi(TCCR1A,WGMA0);
// clear (disable) clear-timer-on-compare-match
//cbi(TCCR1B,CTC1);
// set PWM1A/B/C (OutputCompare action) to none
timer1PWMAOff();
timer1PWMBOff();
timer1PWMCOff();
}
void timer1PWMAOn(void)
{
// turn on channel A (OC1A) PWM output
// set OC1A as non-inverted PWM
sbi(TCCR1A,COMA1);
cbi(TCCR1A,COMA0);
}
void timer1PWMBOn(void)
{
// turn on channel B (OC1B) PWM output
// set OC1B as non-inverted PWM
sbi(TCCR1A,COMB1);
cbi(TCCR1A,COMB0);
}
void timer1PWMCOn(void)
{
// turn on channel C (OC1C) PWM output
// set OC1C as non-inverted PWM
sbi(TCCR1A,COMC1);
cbi(TCCR1A,COMC0);
}
void timer1PWMAOff(void)
{
// turn off channel A (OC1A) PWM output
// set OC1A (OutputCompare action) to none
cbi(TCCR1A,COMA1);
cbi(TCCR1A,COMA0);
}
void timer1PWMBOff(void)
{
// turn off channel B (OC1B) PWM output
// set OC1B (OutputCompare action) to none
cbi(TCCR1A,COMB1);
cbi(TCCR1A,COMB0);
}
void timer1PWMCOff(void)
{
// turn off channel C (OC1C) PWM output
// set OC1C (OutputCompare action) to none
cbi(TCCR1A,COMC1);
cbi(TCCR1A,COMC0);
}
void timer1PWMASet(u16 pwmDuty)
{
// set PWM (output compare) duty for channel A
// this PWM output is generated on OC1A pin
// NOTE: pwmDuty should be in the range 0-255 for 8bit PWM
// pwmDuty should be in the range 0-511 for 9bit PWM
// pwmDuty should be in the range 0-1023 for 10bit PWM
outb(OCR1AH, (pwmDuty>>8)); // set the high 8bits of OCR1A
outb(OCR1AL, (pwmDuty&0x00FF)); // set the low 8bits of OCR1A
}
void timer1PWMBSet(u16 pwmDuty)
{
// set PWM (output compare) duty for channel B
// this PWM output is generated on OC1B pin
// NOTE: pwmDuty should be in the range 0-255 for 8bit PWM
// pwmDuty should be in the range 0-511 for 9bit PWM
// pwmDuty should be in the range 0-1023 for 10bit PWM
outb(OCR1BH, (pwmDuty>>8)); // set the high 8bits of OCR1B
outb(OCR1BL, (pwmDuty&0x00FF)); // set the low 8bits of OCR1B
}
void timer1PWMCSet(u16 pwmDuty)
{
// set PWM (output compare) duty for channel C
// this PWM output is generated on OC1C pin
// NOTE: pwmDuty should be in the range 0-255 for 8bit PWM
// pwmDuty should be in the range 0-511 for 9bit PWM
// pwmDuty should be in the range 0-1023 for 10bit PWM
outb(OCR1CH, (pwmDuty>>8)); // set the high 8bits of OCR1C
outb(OCR1CL, (pwmDuty&0x00FF)); // set the low 8bits of OCR1C
}
void timer3PWMInit(u08 bitRes)
{
// configures timer1 for use with PWM output
// on pins OC3A, OC3B, and OC3C
// enable Timer3 as 8,9,10bit PWM
if(bitRes == 9)
{ // 9bit mode
sbi(TCCR3A,WGMA1);
cbi(TCCR3A,WGMA0);
}
else if( bitRes == 10 )
{ // 10bit mode
sbi(TCCR3A,WGMA1);
sbi(TCCR3A,WGMA0);
}
else
{ // default 8bit mode
cbi(TCCR3A,WGMA1);
sbi(TCCR3A,WGMA0);
}
// set clear-timer-on-compare-match
//cbi(TCCR3B,CTC1);
// clear output compare value A
outb(OCR3AH, 0);
outb(OCR3AL, 0);
// clear output compare value B
outb(OCR3BH, 0);
outb(OCR3BL, 0);
// clear output compare value B
outb(OCR3CH, 0);
outb(OCR3CL, 0);
}
void timer3PWMInitICR(u16 topcount)
{
// set PWM mode with ICR top-count
cbi(TCCR3A,WGM30);
sbi(TCCR3A,WGM31);
sbi(TCCR3B,WGM32);
sbi(TCCR3B,WGM33);
// set top count value
ICR3H = (u08)(topcount>>8);
ICR3L = (u08)topcount;
// clear output compare value A
outb(OCR3AH, 0);
outb(OCR3AL, 0);
// clear output compare value B
outb(OCR3BH, 0);
outb(OCR3BL, 0);
// clear output compare value C
outb(OCR3CH, 0);
outb(OCR3CL, 0);
}
void timer3PWMOff(void)
{
// turn off PWM mode on Timer3
cbi(TCCR3A,WGMA1);
cbi(TCCR3A,WGMA0);
// clear (disable) clear-timer-on-compare-match
//cbi(TCCR3B,CTC1);
// set OC3A/B/C (OutputCompare action) to none
timer3PWMAOff();
timer3PWMBOff();
timer3PWMCOff();
}
void timer3PWMAOn(void)
{
// turn on channel A (OC3A) PWM output
// set OC3A as non-inverted PWM
sbi(TCCR3A,COMA1);
cbi(TCCR3A,COMA0);
}
void timer3PWMBOn(void)
{
// turn on channel B (OC3B) PWM output
// set OC3B as non-inverted PWM
sbi(TCCR3A,COMB1);
cbi(TCCR3A,COMB0);
}
void timer3PWMCOn(void)
{
// turn on channel C (OC3C) PWM output
// set OC3C as non-inverted PWM
sbi(TCCR3A,COMC1);
cbi(TCCR3A,COMC0);
}
void timer3PWMAOff(void)
{
// turn off channel A (OC3A) PWM output
// set OC3A (OutputCompare action) to none
cbi(TCCR3A,COMA1);
cbi(TCCR3A,COMA0);
}
void timer3PWMBOff(void)
{
// turn off channel B (OC3B) PWM output
// set OC3B (OutputCompare action) to none
cbi(TCCR3A,COMB1);
cbi(TCCR3A,COMB0);
}
void timer3PWMCOff(void)
{
// turn off channel C (OC3C) PWM output
// set OC3C (OutputCompare action) to none
cbi(TCCR3A,COMC1);
cbi(TCCR3A,COMC0);
}
void timer3PWMASet(u16 pwmDuty)
{
// set PWM (output compare) duty for channel A
// this PWM output is generated on OC3A pin
// NOTE: pwmDuty should be in the range 0-255 for 8bit PWM
// pwmDuty should be in the range 0-511 for 9bit PWM
// pwmDuty should be in the range 0-1023 for 10bit PWM
outb(OCR3AH, (pwmDuty>>8)); // set the high 8bits of OCR3A
outb(OCR3AL, (pwmDuty&0x00FF)); // set the low 8bits of OCR3A
}
void timer3PWMBSet(u16 pwmDuty)
{
// set PWM (output compare) duty for channel B
// this PWM output is generated on OC3B pin
// NOTE: pwmDuty should be in the range 0-255 for 8bit PWM
// pwmDuty should be in the range 0-511 for 9bit PWM
// pwmDuty should be in the range 0-1023 for 10bit PWM
outb(OCR3BH, (pwmDuty>>8)); // set the high 8bits of OCR3B
outb(OCR3BL, (pwmDuty&0x00FF)); // set the low 8bits of OCR3B
}
void timer3PWMCSet(u16 pwmDuty)
{
// set PWM (output compare) duty for channel B
// this PWM output is generated on OC3C pin
// NOTE: pwmDuty should be in the range 0-255 for 8bit PWM
// pwmDuty should be in the range 0-511 for 9bit PWM
// pwmDuty should be in the range 0-1023 for 10bit PWM
outb(OCR3CH, (pwmDuty>>8)); // set the high 8bits of OCR3C
outb(OCR3CL, (pwmDuty&0x00FF)); // set the low 8bits of OCR3C
}
//! Interrupt handler for tcnt0 overflow interrupt
TIMER_INTERRUPT_HANDLER(TIMER0_OVF_vect)
{
Timer0Reg0++; // increment low-order counter
if(!Timer0Reg0) // if low-order counter rollover
Timer0Reg1++; // increment high-order counter
// if a user function is defined, execute it too
if(TimerIntFunc[TIMER0OVERFLOW_INT])
TimerIntFunc[TIMER0OVERFLOW_INT]();
}
//! Interrupt handler for Timer1 overflow interrupt
TIMER_INTERRUPT_HANDLER(TIMER1_OVF_vect)
{
// if a user function is defined, execute it
if(TimerIntFunc[TIMER1OVERFLOW_INT])
TimerIntFunc[TIMER1OVERFLOW_INT]();
}
//! Interrupt handler for Timer2 overflow interrupt
TIMER_INTERRUPT_HANDLER(TIMER2_OVF_vect)
{
Timer2Reg0++; // increment low-order counter
if(!Timer2Reg0) // if low-order counter rollover
Timer2Reg1++; // increment high-order counter
// increment pause counter
TimerPauseReg++;
// if a user function is defined, execute it
if(TimerIntFunc[TIMER2OVERFLOW_INT])
TimerIntFunc[TIMER2OVERFLOW_INT]();
}
//! Interrupt handler for Timer3 overflow interrupt
TIMER_INTERRUPT_HANDLER(TIMER3_OVF_vect)
{
// if a user function is defined, execute it
if(TimerIntFunc[TIMER3OVERFLOW_INT])
TimerIntFunc[TIMER3OVERFLOW_INT]();
}
//! Interrupt handler for OutputCompare0 match (OC0) interrupt
TIMER_INTERRUPT_HANDLER(TIMER0_COMP_vect)
{
// if a user function is defined, execute it
if(TimerIntFunc[TIMER0OUTCOMPARE_INT])
TimerIntFunc[TIMER0OUTCOMPARE_INT]();
}
//! Interrupt handler for OutputCompare1A match (OC1A) interrupt
TIMER_INTERRUPT_HANDLER(TIMER1_COMPA_vect)
{
// if a user function is defined, execute it
if(TimerIntFunc[TIMER1OUTCOMPAREA_INT])
TimerIntFunc[TIMER1OUTCOMPAREA_INT]();
}
//! Interrupt handler for OutputCompare1B match (OC1B) interrupt
TIMER_INTERRUPT_HANDLER(TIMER1_COMPB_vect)
{
// if a user function is defined, execute it
if(TimerIntFunc[TIMER1OUTCOMPAREB_INT])
TimerIntFunc[TIMER1OUTCOMPAREB_INT]();
}
//! Interrupt handler for OutputCompare1C match (OC1C) interrupt
TIMER_INTERRUPT_HANDLER(TIMER1_COMPC_vect)
{
// if a user function is defined, execute it
if(TimerIntFunc[TIMER1OUTCOMPAREC_INT])
TimerIntFunc[TIMER1OUTCOMPAREC_INT]();
}
//! Interrupt handler for InputCapture1(IC1) interrupt
TIMER_INTERRUPT_HANDLER(TIMER1_CAPT_vect)
{
// if a user function is defined, execute it
if(TimerIntFunc[TIMER1INPUTCAPTURE_INT])
TimerIntFunc[TIMER1INPUTCAPTURE_INT]();
}
//! Interrupt handler for OutputCompare2 match (OC2) interrupt
TIMER_INTERRUPT_HANDLER(TIMER2_COMP_vect)
{
// if a user function is defined, execute it
if(TimerIntFunc[TIMER2OUTCOMPARE_INT])
TimerIntFunc[TIMER2OUTCOMPARE_INT]();
}
//! Interrupt handler for OutputCompare3A match (OC3A) interrupt
TIMER_INTERRUPT_HANDLER(TIMER3_COMPA_vect)
{
// if a user function is defined, execute it
if(TimerIntFunc[TIMER3OUTCOMPAREA_INT])
TimerIntFunc[TIMER3OUTCOMPAREA_INT]();
}
//! Interrupt handler for OutputCompare3B match (OC3B) interrupt
TIMER_INTERRUPT_HANDLER(TIMER3_COMPB_vect)
{
// if a user function is defined, execute it
if(TimerIntFunc[TIMER3OUTCOMPAREB_INT])
TimerIntFunc[TIMER3OUTCOMPAREB_INT]();
}
//! Interrupt handler for OutputCompare3C match (OC3C) interrupt
TIMER_INTERRUPT_HANDLER(TIMER3_COMPC_vect)
{
// if a user function is defined, execute it
if(TimerIntFunc[TIMER3OUTCOMPAREC_INT])
TimerIntFunc[TIMER3OUTCOMPAREC_INT]();
}
//! Interrupt handler for InputCapture3 (IC3) interrupt
TIMER_INTERRUPT_HANDLER(TIMER3_CAPT_vect)
{
// if a user function is defined, execute it
if(TimerIntFunc[TIMER3INPUTCAPTURE_INT])
TimerIntFunc[TIMER3INPUTCAPTURE_INT]();
}