Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

timer128.c

Go to the documentation of this file.
00001 /*! \file timer128.c \brief System Timer function library for Mega128. */
00002 //*****************************************************************************
00003 //
00004 // File Name    : 'timer128.c'
00005 // Title        : System Timer function library for Mega128
00006 // Author       : Pascal Stang - Copyright (C) 2000-2003
00007 // Created      : 11/22/2000
00008 // Revised      : 02/24/2003
00009 // Version      : 1.2
00010 // Target MCU   : Atmel AVR Series
00011 // Editor Tabs  : 4
00012 //
00013 // This code is distributed under the GNU Public License
00014 //      which can be found at http://www.gnu.org/licenses/gpl.txt
00015 //
00016 //*****************************************************************************
00017 
00018 #include <avr/io.h>
00019 #include <avr/interrupt.h>
00020 #include <avr/pgmspace.h>
00021 #include <avr/sleep.h>
00022 
00023 #include "global.h"
00024 #include "timer128.h"
00025 
00026 // Program ROM constants
00027 // the prescale division values stored in order of timer control register index
00028 // STOP, CLK, CLK/8, CLK/64, CLK/256, CLK/1024
00029 unsigned short __attribute__ ((progmem)) TimerPrescaleFactor[] = {0,1,8,64,256,1024};
00030 // the prescale division values stored in order of timer control register index
00031 // STOP, CLK, CLK/8, CLK/32, CLK/64, CLK/128, CLK/256, CLK/1024
00032 unsigned short __attribute__ ((progmem)) TimerRTCPrescaleFactor[] = {0,1,8,32,64,128,256,1024};
00033 
00034 // Global variables
00035 // time registers
00036 volatile unsigned long TimerPauseReg;
00037 volatile unsigned long Timer0Reg0;
00038 volatile unsigned long Timer0Reg1;
00039 volatile unsigned long Timer2Reg0;
00040 volatile unsigned long Timer2Reg1;
00041 
00042 typedef void (*voidFuncPtr)(void);
00043 volatile static voidFuncPtr TimerIntFunc[TIMER_NUM_INTERRUPTS];
00044 
00045 // delay for a minimum of <us> microseconds 
00046 // the time resolution is dependent on the time the loop takes 
00047 // e.g. with 4Mhz and 5 cycles per loop, the resolution is 1.25 us 
00048 void delay_us(unsigned short time_us) 
00049 {
00050     unsigned short delay_loops;
00051     register unsigned short i;
00052 
00053     delay_loops = (time_us+3)/5*CYCLES_PER_US; // +3 for rounding up (dirty) 
00054 
00055     // one loop takes 5 cpu cycles 
00056     for (i=0; i < delay_loops; i++) {};
00057 }
00058 /*
00059 void delay_ms(unsigned char time_ms)
00060 {
00061     unsigned short delay_count = F_CPU / 4000;
00062 
00063     unsigned short cnt;
00064     asm volatile ("\n"
00065                   "L_dl1%=:\n\t"
00066                   "mov %A0, %A2\n\t"
00067                   "mov %B0, %B2\n"
00068                   "L_dl2%=:\n\t"
00069                   "sbiw %A0, 1\n\t"
00070                   "brne L_dl2%=\n\t"
00071                   "dec %1\n\t" "brne L_dl1%=\n\t":"=&w" (cnt)
00072                   :"r"(time_ms), "r"((unsigned short) (delay_count))
00073     );
00074 }
00075 */
00076 void timerInit(void)
00077 {
00078     u08 intNum;
00079     // detach all user functions from interrupts
00080     for(intNum=0; intNum<TIMER_NUM_INTERRUPTS; intNum++)
00081         timerDetach(intNum);
00082 
00083     // initialize all timers
00084     timer0Init();
00085     timer1Init();
00086     timer2Init();
00087     timer3Init();
00088     // enable interrupts
00089     sei();
00090 }
00091 
00092 void timer0Init()
00093 {
00094     // initialize timer 0
00095     timer0SetPrescaler( TIMER0PRESCALE );   // set prescaler
00096     outb(TCNT0, 0);                         // reset TCNT0
00097     sbi(TIMSK, TOIE0);                      // enable TCNT0 overflow interrupt
00098 
00099     timer0ClearOverflowCount();             // initialize time registers
00100 }
00101 
00102 void timer1Init(void)
00103 {
00104     // initialize timer 1
00105     timer1SetPrescaler( TIMER1PRESCALE );   // set prescaler
00106     outb(TCNT1H, 0);                        // reset TCNT1
00107     outb(TCNT1L, 0);
00108     sbi(TIMSK, TOIE1);                      // enable TCNT1 overflow
00109 }
00110 
00111 void timer2Init(void)
00112 {
00113     // initialize timer 2
00114     timer2SetPrescaler( TIMER2PRESCALE );   // set prescaler
00115     outb(TCNT2, 0);                         // reset TCNT2
00116     sbi(TIMSK, TOIE2);                      // enable TCNT2 overflow
00117 
00118     timer2ClearOverflowCount();             // initialize time registers
00119 }
00120 
00121 void timer3Init(void)
00122 {
00123     // initialize timer 3
00124     timer3SetPrescaler( TIMER3PRESCALE );   // set prescaler
00125     outb(TCNT3H, 0);                        // reset TCNT3
00126     outb(TCNT3L, 0);
00127     sbi(ETIMSK, TOIE3);                     // enable TCNT3 overflow
00128 }
00129 
00130 void timer0SetPrescaler(u08 prescale)
00131 {
00132     // set prescaler on timer 0
00133     outb(TCCR0, (inb(TCCR0) & ~TIMER_PRESCALE_MASK) | prescale);
00134 }
00135 
00136 void timer1SetPrescaler(u08 prescale)
00137 {
00138     // set prescaler on timer 1
00139     outb(TCCR1B, (inb(TCCR1B) & ~TIMER_PRESCALE_MASK) | prescale);
00140 }
00141 
00142 void timer2SetPrescaler(u08 prescale)
00143 {
00144     // set prescaler on timer 2
00145     outb(TCCR2, (inb(TCCR2) & ~TIMER_PRESCALE_MASK) | prescale);
00146 }
00147 
00148 void timer3SetPrescaler(u08 prescale)
00149 {
00150     // set prescaler on timer 2
00151     outb(TCCR3B, (inb(TCCR3B) & ~TIMER_PRESCALE_MASK) | prescale);
00152 }
00153 
00154 u16 timer0GetPrescaler(void)
00155 {
00156     // get the current prescaler setting
00157     return (pgm_read_word(TimerPrescaleFactor+(inb(TCCR0) & TIMER_PRESCALE_MASK)));
00158 }
00159 
00160 u16 timer1GetPrescaler(void)
00161 {
00162     // get the current prescaler setting
00163     return (pgm_read_word(TimerPrescaleFactor+(inb(TCCR1B) & TIMER_PRESCALE_MASK)));
00164 }
00165 
00166 u16 timer2GetPrescaler(void)
00167 {
00168     // get the current prescaler setting
00169     return (pgm_read_word(TimerPrescaleFactor+(inb(TCCR2) & TIMER_PRESCALE_MASK)));
00170 }
00171 
00172 u16 timer3GetPrescaler(void)
00173 {
00174     // get the current prescaler setting
00175     return (pgm_read_word(TimerPrescaleFactor+(inb(TCCR3B) & TIMER_PRESCALE_MASK)));
00176 }
00177 
00178 void timerAttach(u08 interruptNum, void (*userFunc)(void) )
00179 {
00180     // make sure the interrupt number is within bounds
00181     if(interruptNum < TIMER_NUM_INTERRUPTS)
00182     {
00183         // set the interrupt function to run
00184         // the supplied user's function
00185         TimerIntFunc[interruptNum] = userFunc;
00186     }
00187 }
00188 
00189 void timerDetach(u08 interruptNum)
00190 {
00191     // make sure the interrupt number is within bounds
00192     if(interruptNum < TIMER_NUM_INTERRUPTS)
00193     {
00194         // set the interrupt function to run nothing
00195         TimerIntFunc[interruptNum] = 0;
00196     }
00197 }
00198 
00199 void timerPause(unsigned short pause_ms)
00200 {
00201     // pauses for exactly <pause_ms> number of milliseconds
00202     u08 timerThres;
00203     u32 ticRateHz;
00204     u32 pause;
00205 
00206     // capture current pause timer value
00207     timerThres = inb(TCNT2);
00208     // reset pause timer overflow count
00209     TimerPauseReg = 0;
00210     // calculate delay for [pause_ms] milliseconds
00211     // prescaler division = 1<<(pgm_read_byte(TimerPrescaleFactor+inb(TCCR2)))
00212     ticRateHz = F_CPU/timer2GetPrescaler();
00213     // precision management
00214     // prevent overflow and precision underflow
00215     //  -could add more conditions to improve accuracy
00216     if( ((ticRateHz < 429497) && (pause_ms <= 10000)) )
00217         pause = (pause_ms*ticRateHz)/1000;
00218     else
00219         pause = pause_ms*(ticRateHz/1000);
00220     
00221     // loop until time expires
00222     while( ((TimerPauseReg<<8) | inb(TCNT2)) < (pause+timerThres) )
00223     {
00224         if( TimerPauseReg < (pause>>8));
00225         {
00226             // save power by idling the processor
00227             set_sleep_mode(SLEEP_MODE_IDLE);
00228             sleep_mode();
00229         }
00230     }
00231 }
00232 
00233 void timer0ClearOverflowCount(void)
00234 {
00235     // clear the timer overflow counter registers
00236     Timer0Reg0 = 0; // initialize time registers
00237     Timer0Reg1 = 0; // initialize time registers
00238 }
00239 
00240 long timer0GetOverflowCount(void)
00241 {
00242     // return the current timer overflow count
00243     // (this is since the last timer0ClearOverflowCount() command was called)
00244     return Timer0Reg0;
00245 }
00246 
00247 void timer2ClearOverflowCount(void)
00248 {
00249     // clear the timer overflow counter registers
00250     Timer2Reg0 = 0; // initialize time registers
00251     Timer2Reg1 = 0; // initialize time registers
00252 }
00253 
00254 long timer2GetOverflowCount(void)
00255 {
00256     // return the current timer overflow count
00257     // (this is since the last timer2ClearOverflowCount() command was called)
00258     return Timer2Reg0;
00259 }
00260 
00261 
00262 void timer1PWMInit(u08 bitRes)
00263 {
00264     // configures timer1 for use with PWM output
00265     // on pins OC1A, OC1B, and OC1C
00266 
00267     // enable Timer1 as 8,9,10bit PWM
00268     if(bitRes == 9)
00269     {   // 9bit mode
00270         sbi(TCCR1A,WGMA1);
00271         cbi(TCCR1A,WGMA0);
00272     }
00273     else if( bitRes == 10 )
00274     {   // 10bit mode
00275         sbi(TCCR1A,WGMA1);
00276         sbi(TCCR1A,WGMA0);
00277     }
00278     else
00279     {   // default 8bit mode
00280         cbi(TCCR1A,WGMA1);
00281         sbi(TCCR1A,WGMA0);
00282     }
00283 
00284     // set clear-timer-on-compare-match
00285     //cbi(TCCR1B,CTC1);
00286     // clear output compare value A
00287     outb(OCR1AH, 0);
00288     outb(OCR1AL, 0);
00289     // clear output compare value B
00290     outb(OCR1BH, 0);
00291     outb(OCR1BL, 0);
00292     // clear output compare value C
00293     outb(OCR1CH, 0);
00294     outb(OCR1CL, 0);
00295 }
00296 
00297 void timer1PWMInitICR(u16 topcount)
00298 {
00299     // set PWM mode with ICR top-count
00300     cbi(TCCR1A,WGM10);
00301     sbi(TCCR1A,WGM11);
00302     sbi(TCCR1B,WGM12);
00303     sbi(TCCR1B,WGM13);
00304     
00305     // set top count value
00306     ICR1H = (u08)(topcount>>8);
00307     ICR1L = (u08)topcount;
00308     
00309     // clear output compare value A
00310     outb(OCR1AH, 0);
00311     outb(OCR1AL, 0);
00312     // clear output compare value B
00313     outb(OCR1BH, 0);
00314     outb(OCR1BL, 0);
00315     // clear output compare value C
00316     outb(OCR1CH, 0);
00317     outb(OCR1CL, 0);
00318 }
00319 
00320 void timer1PWMOff(void)
00321 {
00322     // turn off PWM on Timer1
00323     cbi(TCCR1A,WGMA1);
00324     cbi(TCCR1A,WGMA0);
00325     // clear (disable) clear-timer-on-compare-match
00326     //cbi(TCCR1B,CTC1);
00327     // set PWM1A/B/C (OutputCompare action) to none
00328     timer1PWMAOff();
00329     timer1PWMBOff();
00330     timer1PWMCOff();
00331 }
00332 
00333 void timer1PWMAOn(void)
00334 {
00335     // turn on channel A (OC1A) PWM output
00336     // set OC1A as non-inverted PWM
00337     sbi(TCCR1A,COMA1);
00338     cbi(TCCR1A,COMA0);
00339 }
00340 
00341 void timer1PWMBOn(void)
00342 {
00343     // turn on channel B (OC1B) PWM output
00344     // set OC1B as non-inverted PWM
00345     sbi(TCCR1A,COMB1);
00346     cbi(TCCR1A,COMB0);
00347 }
00348 
00349 void timer1PWMCOn(void)
00350 {
00351     // turn on channel C (OC1C) PWM output
00352     // set OC1C as non-inverted PWM
00353     sbi(TCCR1A,COMC1);
00354     cbi(TCCR1A,COMC0);
00355 }
00356 
00357 void timer1PWMAOff(void)
00358 {
00359     // turn off channel A (OC1A) PWM output
00360     // set OC1A (OutputCompare action) to none
00361     cbi(TCCR1A,COMA1);
00362     cbi(TCCR1A,COMA0);
00363 }
00364 
00365 void timer1PWMBOff(void)
00366 {
00367     // turn off channel B (OC1B) PWM output
00368     // set OC1B (OutputCompare action) to none
00369     cbi(TCCR1A,COMB1);
00370     cbi(TCCR1A,COMB0);
00371 }
00372 
00373 void timer1PWMCOff(void)
00374 {
00375     // turn off channel C (OC1C) PWM output
00376     // set OC1C (OutputCompare action) to none
00377     cbi(TCCR1A,COMC1);
00378     cbi(TCCR1A,COMC0);
00379 }
00380 
00381 void timer1PWMASet(u16 pwmDuty)
00382 {
00383     // set PWM (output compare) duty for channel A
00384     // this PWM output is generated on OC1A pin
00385     // NOTE:    pwmDuty should be in the range 0-255 for 8bit PWM
00386     //          pwmDuty should be in the range 0-511 for 9bit PWM
00387     //          pwmDuty should be in the range 0-1023 for 10bit PWM
00388     outb(OCR1AH, (pwmDuty>>8));     // set the high 8bits of OCR1A
00389     outb(OCR1AL, (pwmDuty&0x00FF)); // set the low 8bits of OCR1A
00390 }
00391 
00392 void timer1PWMBSet(u16 pwmDuty)
00393 {
00394     // set PWM (output compare) duty for channel B
00395     // this PWM output is generated on OC1B pin
00396     // NOTE:    pwmDuty should be in the range 0-255 for 8bit PWM
00397     //          pwmDuty should be in the range 0-511 for 9bit PWM
00398     //          pwmDuty should be in the range 0-1023 for 10bit PWM
00399     outb(OCR1BH, (pwmDuty>>8));     // set the high 8bits of OCR1B
00400     outb(OCR1BL, (pwmDuty&0x00FF)); // set the low 8bits of OCR1B
00401 }
00402 
00403 void timer1PWMCSet(u16 pwmDuty)
00404 {
00405     // set PWM (output compare) duty for channel C
00406     // this PWM output is generated on OC1C pin
00407     // NOTE:    pwmDuty should be in the range 0-255 for 8bit PWM
00408     //          pwmDuty should be in the range 0-511 for 9bit PWM
00409     //          pwmDuty should be in the range 0-1023 for 10bit PWM
00410     outb(OCR1CH, (pwmDuty>>8));     // set the high 8bits of OCR1C
00411     outb(OCR1CL, (pwmDuty&0x00FF)); // set the low 8bits of OCR1C
00412 }
00413 
00414 
00415 void timer3PWMInit(u08 bitRes)
00416 {
00417     // configures timer1 for use with PWM output
00418     // on pins OC3A, OC3B, and OC3C
00419 
00420     // enable Timer3 as 8,9,10bit PWM
00421     if(bitRes == 9)
00422     {   // 9bit mode
00423         sbi(TCCR3A,WGMA1);
00424         cbi(TCCR3A,WGMA0);
00425     }
00426     else if( bitRes == 10 )
00427     {   // 10bit mode
00428         sbi(TCCR3A,WGMA1);
00429         sbi(TCCR3A,WGMA0);
00430     }
00431     else
00432     {   // default 8bit mode
00433         cbi(TCCR3A,WGMA1);
00434         sbi(TCCR3A,WGMA0);
00435     }
00436 
00437     // set clear-timer-on-compare-match
00438     //cbi(TCCR3B,CTC1);
00439     // clear output compare value A
00440     outb(OCR3AH, 0);
00441     outb(OCR3AL, 0);
00442     // clear output compare value B
00443     outb(OCR3BH, 0);
00444     outb(OCR3BL, 0);
00445     // clear output compare value B
00446     outb(OCR3CH, 0);
00447     outb(OCR3CL, 0);
00448 }
00449 
00450 void timer3PWMInitICR(u16 topcount)
00451 {
00452     // set PWM mode with ICR top-count
00453     cbi(TCCR3A,WGM30);
00454     sbi(TCCR3A,WGM31);
00455     sbi(TCCR3B,WGM32);
00456     sbi(TCCR3B,WGM33);
00457     
00458     // set top count value
00459     ICR3H = (u08)(topcount>>8);
00460     ICR3L = (u08)topcount;
00461     
00462     // clear output compare value A
00463     outb(OCR3AH, 0);
00464     outb(OCR3AL, 0);
00465     // clear output compare value B
00466     outb(OCR3BH, 0);
00467     outb(OCR3BL, 0);
00468     // clear output compare value C
00469     outb(OCR3CH, 0);
00470     outb(OCR3CL, 0);
00471 }
00472 
00473 void timer3PWMOff(void)
00474 {
00475     // turn off PWM mode on Timer3
00476     cbi(TCCR3A,WGMA1);
00477     cbi(TCCR3A,WGMA0);
00478     // clear (disable) clear-timer-on-compare-match
00479     //cbi(TCCR3B,CTC1);
00480     // set OC3A/B/C (OutputCompare action) to none
00481     timer3PWMAOff();
00482     timer3PWMBOff();
00483     timer3PWMCOff();
00484 }
00485 
00486 void timer3PWMAOn(void)
00487 {
00488     // turn on channel A (OC3A) PWM output
00489     // set OC3A as non-inverted PWM
00490     sbi(TCCR3A,COMA1);
00491     cbi(TCCR3A,COMA0);
00492 }
00493 
00494 void timer3PWMBOn(void)
00495 {
00496     // turn on channel B (OC3B) PWM output
00497     // set OC3B as non-inverted PWM
00498     sbi(TCCR3A,COMB1);
00499     cbi(TCCR3A,COMB0);
00500 }
00501 
00502 void timer3PWMCOn(void)
00503 {
00504     // turn on channel C (OC3C) PWM output
00505     // set OC3C as non-inverted PWM
00506     sbi(TCCR3A,COMC1);
00507     cbi(TCCR3A,COMC0);
00508 }
00509 
00510 void timer3PWMAOff(void)
00511 {
00512     // turn off channel A (OC3A) PWM output
00513     // set OC3A (OutputCompare action) to none
00514     cbi(TCCR3A,COMA1);
00515     cbi(TCCR3A,COMA0);
00516 }
00517 
00518 void timer3PWMBOff(void)
00519 {
00520     // turn off channel B (OC3B) PWM output
00521     // set OC3B (OutputCompare action) to none
00522     cbi(TCCR3A,COMB1);
00523     cbi(TCCR3A,COMB0);
00524 }
00525 
00526 void timer3PWMCOff(void)
00527 {
00528     // turn off channel C (OC3C) PWM output
00529     // set OC3C (OutputCompare action) to none
00530     cbi(TCCR3A,COMC1);
00531     cbi(TCCR3A,COMC0);
00532 }
00533 
00534 void timer3PWMASet(u16 pwmDuty)
00535 {
00536     // set PWM (output compare) duty for channel A
00537     // this PWM output is generated on OC3A pin
00538     // NOTE:    pwmDuty should be in the range 0-255 for 8bit PWM
00539     //          pwmDuty should be in the range 0-511 for 9bit PWM
00540     //          pwmDuty should be in the range 0-1023 for 10bit PWM
00541     outb(OCR3AH, (pwmDuty>>8));     // set the high 8bits of OCR3A
00542     outb(OCR3AL, (pwmDuty&0x00FF)); // set the low 8bits of OCR3A
00543 }
00544 
00545 void timer3PWMBSet(u16 pwmDuty)
00546 {
00547     // set PWM (output compare) duty for channel B
00548     // this PWM output is generated on OC3B pin
00549     // NOTE:    pwmDuty should be in the range 0-255 for 8bit PWM
00550     //          pwmDuty should be in the range 0-511 for 9bit PWM
00551     //          pwmDuty should be in the range 0-1023 for 10bit PWM
00552     outb(OCR3BH, (pwmDuty>>8));     // set the high 8bits of OCR3B
00553     outb(OCR3BL, (pwmDuty&0x00FF)); // set the low 8bits of OCR3B
00554 }
00555 
00556 void timer3PWMCSet(u16 pwmDuty)
00557 {
00558     // set PWM (output compare) duty for channel B
00559     // this PWM output is generated on OC3C pin
00560     // NOTE:    pwmDuty should be in the range 0-255 for 8bit PWM
00561     //          pwmDuty should be in the range 0-511 for 9bit PWM
00562     //          pwmDuty should be in the range 0-1023 for 10bit PWM
00563     outb(OCR3CH, (pwmDuty>>8));     // set the high 8bits of OCR3C
00564     outb(OCR3CL, (pwmDuty&0x00FF)); // set the low 8bits of OCR3C
00565 }
00566 
00567 
00568 //! Interrupt handler for tcnt0 overflow interrupt
00569 TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW0)
00570 {
00571     Timer0Reg0++;       // increment low-order counter
00572     if(!Timer0Reg0)     // if low-order counter rollover
00573         Timer0Reg1++;   // increment high-order counter 
00574 
00575     // if a user function is defined, execute it too
00576     if(TimerIntFunc[TIMER0OVERFLOW_INT])
00577         TimerIntFunc[TIMER0OVERFLOW_INT]();
00578 }
00579 
00580 //! Interrupt handler for Timer1 overflow interrupt
00581 TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW1)
00582 {
00583     // if a user function is defined, execute it
00584     if(TimerIntFunc[TIMER1OVERFLOW_INT])
00585         TimerIntFunc[TIMER1OVERFLOW_INT]();
00586 }
00587 
00588 //! Interrupt handler for Timer2 overflow interrupt
00589 TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW2)
00590 {
00591     Timer2Reg0++;       // increment low-order counter
00592     if(!Timer2Reg0)     // if low-order counter rollover
00593         Timer2Reg1++;   // increment high-order counter 
00594 
00595     // increment pause counter
00596     TimerPauseReg++;
00597 
00598     // if a user function is defined, execute it
00599     if(TimerIntFunc[TIMER2OVERFLOW_INT])
00600         TimerIntFunc[TIMER2OVERFLOW_INT]();
00601 }
00602 
00603 //! Interrupt handler for Timer3 overflow interrupt
00604 TIMER_INTERRUPT_HANDLER(SIG_OVERFLOW3)
00605 {
00606     // if a user function is defined, execute it
00607     if(TimerIntFunc[TIMER3OVERFLOW_INT])
00608         TimerIntFunc[TIMER3OVERFLOW_INT]();
00609 }
00610 
00611 //! Interrupt handler for OutputCompare0 match (OC0) interrupt
00612 TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE0)
00613 {
00614     // if a user function is defined, execute it
00615     if(TimerIntFunc[TIMER0OUTCOMPARE_INT])
00616         TimerIntFunc[TIMER0OUTCOMPARE_INT]();
00617 }
00618 
00619 //! Interrupt handler for OutputCompare1A match (OC1A) interrupt
00620 TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE1A)
00621 {
00622     // if a user function is defined, execute it
00623     if(TimerIntFunc[TIMER1OUTCOMPAREA_INT])
00624         TimerIntFunc[TIMER1OUTCOMPAREA_INT]();
00625 }
00626 
00627 //! Interrupt handler for OutputCompare1B match (OC1B) interrupt
00628 TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE1B)
00629 {
00630     // if a user function is defined, execute it
00631     if(TimerIntFunc[TIMER1OUTCOMPAREB_INT])
00632         TimerIntFunc[TIMER1OUTCOMPAREB_INT]();
00633 }
00634 
00635 //! Interrupt handler for OutputCompare1C match (OC1C) interrupt
00636 TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE1C)
00637 {
00638     // if a user function is defined, execute it
00639     if(TimerIntFunc[TIMER1OUTCOMPAREC_INT])
00640         TimerIntFunc[TIMER1OUTCOMPAREC_INT]();
00641 }
00642 
00643 //! Interrupt handler for InputCapture1(IC1) interrupt
00644 TIMER_INTERRUPT_HANDLER(SIG_INPUT_CAPTURE1)
00645 {
00646     // if a user function is defined, execute it
00647     if(TimerIntFunc[TIMER1INPUTCAPTURE_INT])
00648         TimerIntFunc[TIMER1INPUTCAPTURE_INT]();
00649 }
00650 
00651 //! Interrupt handler for OutputCompare2 match (OC2) interrupt
00652 TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE2)
00653 {
00654     // if a user function is defined, execute it
00655     if(TimerIntFunc[TIMER2OUTCOMPARE_INT])
00656         TimerIntFunc[TIMER2OUTCOMPARE_INT]();
00657 }
00658 
00659 //! Interrupt handler for OutputCompare3A match (OC3A) interrupt
00660 TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE3A)
00661 {
00662     // if a user function is defined, execute it
00663     if(TimerIntFunc[TIMER3OUTCOMPAREA_INT])
00664         TimerIntFunc[TIMER3OUTCOMPAREA_INT]();
00665 }
00666 
00667 //! Interrupt handler for OutputCompare3B match (OC3B) interrupt
00668 TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE3B)
00669 {
00670     // if a user function is defined, execute it
00671     if(TimerIntFunc[TIMER3OUTCOMPAREB_INT])
00672         TimerIntFunc[TIMER3OUTCOMPAREB_INT]();
00673 }
00674 
00675 //! Interrupt handler for OutputCompare3C match (OC3C) interrupt
00676 TIMER_INTERRUPT_HANDLER(SIG_OUTPUT_COMPARE3C)
00677 {
00678     // if a user function is defined, execute it
00679     if(TimerIntFunc[TIMER3OUTCOMPAREC_INT])
00680         TimerIntFunc[TIMER3OUTCOMPAREC_INT]();
00681 }
00682 
00683 //! Interrupt handler for InputCapture3 (IC3) interrupt
00684 TIMER_INTERRUPT_HANDLER(SIG_INPUT_CAPTURE3)
00685 {
00686     // if a user function is defined, execute it
00687     if(TimerIntFunc[TIMER3INPUTCAPTURE_INT])
00688         TimerIntFunc[TIMER3INPUTCAPTURE_INT]();
00689 }

Generated on Sun Oct 29 03:41:07 2006 for Procyon AVRlib by  doxygen 1.4.2