avr/cpp/atmega8/Timer.h

Go to the documentation of this file.
00001 /**********************************************************************************************************************\
00002 
00003         C++ library for Atmel AVR microcontrollers
00004         Copyright (C) 2007 Lauri Kirikal, Mikk Leini, MT� TT� Robotiklubi
00005 
00006         This program is free software; you can redistribute it and/or
00007         modify it under the terms of the GNU General Public License
00008         as published by the Free Software Foundation; either version 2
00009         of the License, or (at your option) any later version.
00010 
00011         This program is distributed in the hope that it will be useful,
00012         but WITHOUT ANY WARRANTY; without even the implied warranty of
00013         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014         GNU General Public License for more details.
00015 
00016         You should have received a copy of the GNU General Public License
00017         along with this program; if not, write to the Free Software
00018         Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00019 
00020         See http://creativecommons.org/licenses/GPL/2.0/
00021 
00022         MT� TT� Robotiklubi  http://www.robotiklubi.ee robotiklubi@gmail.com
00023         Lauri Kirikal        laurikirikal@gmail.com
00024         Mikk Leini           mikk.leini@gmail.com
00025 
00026 \**********************************************************************************************************************/
00027 
00028 #ifndef __AVR_CPP_ATMEGA8_TIMER_H__
00029 #define __AVR_CPP_ATMEGA8_TIMER_H__
00030 
00031 /* This file should only be included from <avr/cpp/Timer.h>, never directly. */
00032 
00033 #ifndef __AVR_CPP_TIMER_H__
00034 #ifdef __DOXYGEN__
00035 #include <avr/cpp/Timer.h>
00036 #else
00037 #error "Include <avr/cpp/Timer.h> instead of <avr/cpp/atmega8/Timer.h>."
00038 #endif
00039 #endif // ifdef __AVR_CPP_TIMER_H__
00040 
00041 #ifndef __AVR_CPP_XXX_TIMER_H__
00042 #define __AVR_CPP_XXX_TIMER_H__ "atmega8/Timer.h"
00043 #else
00044 #error "Attempt to include more than one <avr/cpp/XXX/Timer.h> file."
00045 #endif
00046 
00047 #define TIMER0_OVF_ns   Timer
00048 #define TIMER1_OVF_ns   Timer
00049 #define TIMER1_COMPA_ns Timer
00050 #define TIMER1_COMPB_ns Timer
00051 #define TIMER1_CAPT_ns  Timer
00052 #define TIMER2_COMP_ns  Timer
00053 #define TIMER2_OVF_ns   Timer
00054 
00055 #define TIMER0_OVF_struct       Timer::TimerCounter0::OverflowInterrupt
00056 #define TIMER1_OVF_struct       Timer::TimerCounter1::OverflowInterrupt
00057 #define TIMER1_COMPA_struct     Timer::TimerCounter1::CompareMatchAInterrupt
00058 #define TIMER1_COMPB_struct     Timer::TimerCounter1::CompareMatchBInterrupt
00059 #define TIMER1_CAPT_struct      Timer::TimerCounter1::InputCaptureInterrupt
00060 #define TIMER2_COMP_struct      Timer::TimerCounter2::CompareMatchInterrupt
00061 #define TIMER2_OVF_struct       Timer::TimerCounter2::OverflowInterrupt
00062 
00063 
00064 namespace AVRCpp
00065 {
00066         namespace Timer
00067         {
00068                 inline void PrescalerReset10() { SetBits<_SFIOR>(_PSR10); }
00069                 inline void PrescalerReset2() { SetBits<_SFIOR>(_PSR2); }
00070                 
00071                 
00072                 struct TimerCounter0 : Internal::SimpleTimer <
00073                                 _TCNT0,                         /* CounterRegister */
00074                                 _TCCR0,                         /* ClockRegister */
00075                                 ClockB >                        /* ClockEnum */
00076                 {
00077                         struct OverflowInterrupt : Interrupt<Bits<_TIMSK, _TOIE0>, Bits<_TIFR, _TOV0> > { __INTERRUPT_HANDLER_SUPPORT__ };
00078                         
00079                 }; // TimerCounter0
00080                 
00081                 
00082                 struct TimerCounter1 : Internal::OldTwoChannel16BitTimer <
00083                                 _TCNT1,                         /* CounterRegister */
00084                                 _OCR1A,                         /* OutputCompareRegisterA */
00085                                 _OCR1B,                         /* OutputCompareRegisterB */
00086                                 _ICR1,                          /* InputCaptureRegister */
00087                                 _TCCR1A,                        /* ControlRegisterA */
00088                                 _TCCR1B,                        /* ControlRegisterB */
00089                                 ClockB,                         /* ClockEnum */
00090                                 OutputPin1<PortB>,      /* ChannelAOutputPin */
00091                                 OutputPin2<PortB>,      /* ChannelBOutputPin */
00092                                 InputPin0<PortB> >      /* InputCaptureInputPin */
00093                 {
00094                         struct InputCaptureInterrupt : Interrupt<Bits<_TIMSK, _TICIE1>, Bits<_TIFR, _ICF1> > { __INTERRUPT_HANDLER_SUPPORT__ };
00095                         struct CompareMatchAInterrupt : Interrupt<Bits<_TIMSK, _OCIE1A>, Bits<_TIFR, _OCF1A> > { __INTERRUPT_HANDLER_SUPPORT__ };
00096                         struct CompareMatchBInterrupt : Interrupt<Bits<_TIMSK, _OCIE1B>, Bits<_TIFR, _OCF1B> > { __INTERRUPT_HANDLER_SUPPORT__ };
00097                         struct OverflowInterrupt : Interrupt<Bits<_TIMSK, _TOIE1>, Bits<_TIFR, _TOV1> > { __INTERRUPT_HANDLER_SUPPORT__ };
00098                         
00099                 }; // struct TimerCounter1
00100                 
00101                 
00102                 struct TimerCounter2 : Internal::OneChannel8BitTimerWithAsynchronousOperation <
00103                                 _TCNT2,                                                 /* CounterRegister */
00104                                 _OCR2,                                                  /* OutputCompareRegister */
00105                                 _TCCR2,                                                 /* ControlRegister */
00106                                 _ASSR,                                                  /* AsyncStatusRegister */
00107                                 Bits<_TIMSK, _OCIE2 | _TOIE2>,  /* InterruptEnableBits */
00108                                 Bits<_TIFR, _OCF2 | _TOV2>,             /* InterruptFlagBits */
00109                                 OutputPin3<PortB> >                             /* ChannelOutputPin */
00110                 {
00111                         struct CompareMatchInterrupt : Interrupt<Bits<_TIMSK, _OCIE2>, Bits<_TIFR, _OCF2> > { __INTERRUPT_HANDLER_SUPPORT__ };
00112                         struct OverflowInterrupt : Interrupt<Bits<_TIMSK, _TOIE2>, Bits<_TIFR, _TOV2> > { __INTERRUPT_HANDLER_SUPPORT__ };
00113                         
00114                 }; // struct TimerCounter2
00115                 
00116         } // namespace Timer
00117         
00118 } // namespace AVRCpp
00119 
00120 #endif // ifndef __AVR_CPP_ATMEGA8_TIMER_H__

Generated on Sat Sep 15 23:41:29 2007 for AVR C++ Lib for ATmega8 by  doxygen 1.5.2
SourceForge.net Logo MTÜ TTÜ Robotiklubi