avr/cpp/atmega64/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_ATMEGA64_TIMER_H__
00029 #define __AVR_CPP_ATMEGA64_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/atmega64/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__ "atmega64/Timer.h"
00043 #else
00044 #error "Attempt to include more than one <avr/cpp/XXX/Timer.h> file."
00045 #endif
00046 
00047 #define TIMER0_COMP_ns  Timer
00048 #define TIMER0_OVF_ns   Timer
00049 #define TIMER1_COMPA_ns Timer
00050 #define TIMER1_COMPB_ns Timer
00051 #define TIMER1_COMPC_ns Timer
00052 #define TIMER1_OVF_ns   Timer
00053 #define TIMER1_CAPT_ns  Timer
00054 #define TIMER2_COMP_ns  Timer
00055 #define TIMER2_OVF_ns   Timer
00056 #define TIMER3_COMPA_ns Timer
00057 #define TIMER3_COMPB_ns Timer
00058 #define TIMER3_COMPC_ns Timer
00059 #define TIMER3_OVF_ns   Timer
00060 #define TIMER3_CAPT_ns  Timer
00061 
00062 #define TIMER0_COMP_struct      Timer::TimerCounter0::CompareMatchInterrupt
00063 #define TIMER0_OVF_struct       Timer::TimerCounter0::OverflowInterrupt
00064 
00065 #define TIMER1_COMPA_struct Timer::TimerCounter1::CompareMatchAInterrupt
00066 #define TIMER1_COMPB_struct     Timer::TimerCounter1::CompareMatchBInterrupt
00067 #define TIMER1_COMPC_struct     Timer::TimerCounter1::CompareMatchCInterrupt
00068 #define TIMER1_OVF_struct       Timer::TimerCounter1::OverflowInterrupt
00069 #define TIMER1_CAPT_struct      Timer::TimerCounter1::InputCaptureInterrupt
00070 
00071 #define TIMER2_COMP_struct      Timer::TimerCounter2::CompareMatchInterrupt
00072 #define TIMER2_OVF_struct       Timer::TimerCounter2::OverflowInterrupt
00073 
00074 #define TIMER3_COMPA_struct Timer::TimerCounter3::CompareMatchAInterrupt
00075 #define TIMER3_COMPB_struct     Timer::TimerCounter3::CompareMatchBInterrupt
00076 #define TIMER3_COMPC_struct     Timer::TimerCounter3::CompareMatchCInterrupt
00077 #define TIMER3_OVF_struct       Timer::TimerCounter3::OverflowInterrupt
00078 #define TIMER3_CAPT_struct      Timer::TimerCounter3::InputCaptureInterrupt
00079 
00080 
00081 namespace AVRCpp
00082 {
00083         namespace Timer
00084         {
00085                 inline void StartSynchronization() { SetBits<_SFIOR>(_TSM); }
00086                 inline void EndSynchronization() { ClearBits<_SFIOR>(_TSM); }
00087                 
00088                 inline void PrescalerReset0() { SetBits<_SFIOR>(_PSR0); }
00089                 inline void PrescalerReset321() { SetBits<_SFIOR>(_PSR321); }
00090                 
00091                 
00092                 struct TimerCounter0 : Internal::OneChannel8BitTimerWithAsynchronousOperation <
00093                                 _TCNT0,                                                 /* CounterRegister */
00094                                 _OCR0,                                                  /* OutputCompareRegister */
00095                                 _TCCR0,                                                 /* ControlRegister */
00096                                 _ASSR,                                                  /* AsyncStatusRegister */
00097                                 Bits<_TIMSK, _OCIE0 | _TOIE0>,  /* InterruptEnableBits */
00098                                 Bits<_TIFR, _OCF0 | _TOV0>,             /* InterruptFlagBits */
00099                                 OutputPin4<PortB> >                             /* ChannelOutputPin */
00100                 {
00101                         struct CompareMatchInterrupt : Interrupt<Bits<_TIMSK, _OCIE0>, Bits<_TIFR, _OCF0> > { __INTERRUPT_HANDLER_SUPPORT__ };
00102                         struct OverflowInterrupt : Interrupt<Bits<_TIMSK, _TOIE0>, Bits<_TIFR, _TOV0> > { __INTERRUPT_HANDLER_SUPPORT__ };
00103                         
00104                 }; // struct TimerCounter0
00105                 
00106                 
00107                 struct TimerCounter1 : Internal::ThreeChannel16BitTimer <
00108                                 _TCNT1,                         /* CounterRegister */
00109                                 _OCR1A,                         /* OutputCompareRegisterA */
00110                                 _OCR1B,                         /* OutputCompareRegisterB */
00111                                 _OCR1C,                         /* OutputCompareRegisterC */
00112                                 _ICR1,                          /* InputCaptureRegister */
00113                                 _TCCR1A,                        /* ControlRegisterA */
00114                                 _TCCR1B,                        /* ControlRegisterB */
00115                                 _TCCR1C,                        /* ControlRegisterC */
00116                                 ClockB,                         /* ClockEnum */
00117                                 OutputPin5<PortB>,      /* ChannelAOutputPin */
00118                                 OutputPin6<PortB>,      /* ChannelBOutputPin */
00119                                 OutputPin7<PortB>,      /* ChannelCOutputPin */
00120                                 InputPin4<PortD> >      /* InputCaptureInputPin */
00121                 {
00122                         struct CompareMatchAInterrupt : Interrupt<Bits<_TIMSK, _OCIE1A>, Bits<_TIFR, _OCF1A> > { __INTERRUPT_HANDLER_SUPPORT__ };
00123                         struct CompareMatchBInterrupt : Interrupt<Bits<_TIMSK, _OCIE1B>, Bits<_TIFR, _OCF1B> > { __INTERRUPT_HANDLER_SUPPORT__ };
00124                         struct CompareMatchCInterrupt : Interrupt<Bits<_ETIMSK, _OCIE1C>, Bits<_ETIFR, _OCF1C> > { __INTERRUPT_HANDLER_SUPPORT__ };
00125                         struct OverflowInterrupt : Interrupt<Bits<_TIMSK, _TOIE1>, Bits<_TIFR, _TOV1> > { __INTERRUPT_HANDLER_SUPPORT__ };
00126                         struct InputCaptureInterrupt : Interrupt<Bits<_TIMSK, _TICIE1>, Bits<_TIFR, _ICF1> > { __INTERRUPT_HANDLER_SUPPORT__ };
00127                         
00128                 }; // struct TimerCounter1
00129                 
00130                 
00131                 struct TimerCounter2 : Internal::OneChannel8BitTimer <
00132                                 _TCNT2,                         /* CounterRegister */
00133                                 _OCR2,                          /* OutputCompareRegister */
00134                                 _TCCR2,                         /* ControlRegister */
00135                                 ClockB,                         /* ClockEnum */
00136                                 OutputPin7<PortB> >     /* ChannelOutputPin */
00137                 {
00138                         struct CompareMatchInterrupt : Interrupt<Bits<_TIMSK, _OCIE2>, Bits<_TIFR, _OCF2> > { __INTERRUPT_HANDLER_SUPPORT__ };
00139                         struct OverflowInterrupt : Interrupt<Bits<_TIMSK, _TOIE2>, Bits<_TIFR, _TOV2> > { __INTERRUPT_HANDLER_SUPPORT__ };
00140                         
00141                 }; // struct TimerCounter2
00142                 
00143                 
00144                 struct TimerCounter3 : Internal::ThreeChannel16BitTimer <
00145                                 _TCNT3,                         /* CounterRegister */
00146                                 _OCR3A,                         /* OutputCompareRegisterA */
00147                                 _OCR3B,                         /* OutputCompareRegisterB */
00148                                 _OCR3C,                         /* OutputCompareRegisterC */
00149                                 _ICR3,                          /* InputCaptureRegister */
00150                                 _TCCR3A,                        /* ControlRegisterA */
00151                                 _TCCR3B,                        /* ControlRegisterB */
00152                                 _TCCR3C,                        /* ControlRegisterC */
00153                                 ClockB,                         /* ClockEnum */
00154                                 OutputPin3<PortE>,      /* ChannelAOutputPin */
00155                                 OutputPin4<PortE>,      /* ChannelBOutputPin */
00156                                 OutputPin5<PortE>,      /* ChannelCOutputPin */
00157                                 InputPin7<PortE> >      /* InputCaptureInputPin */
00158                 {
00159                         struct CompareMatchAInterrupt : Interrupt<Bits<_ETIMSK, _OCIE3A>, Bits<_ETIFR, _OCF3A> > { __INTERRUPT_HANDLER_SUPPORT__ };
00160                         struct CompareMatchBInterrupt : Interrupt<Bits<_ETIMSK, _OCIE3B>, Bits<_ETIFR, _OCF3B> > { __INTERRUPT_HANDLER_SUPPORT__ };
00161                         struct CompareMatchCInterrupt : Interrupt<Bits<_ETIMSK, _OCIE3C>, Bits<_ETIFR, _OCF3C> > { __INTERRUPT_HANDLER_SUPPORT__ };
00162                         struct OverflowInterrupt : Interrupt<Bits<_ETIMSK, _TOIE3>, Bits<_ETIFR, _TOV3> > { __INTERRUPT_HANDLER_SUPPORT__ };
00163                         struct InputCaptureInterrupt : Interrupt<Bits<_ETIMSK, _TICIE3>, Bits<_ETIFR, _ICF3> > { __INTERRUPT_HANDLER_SUPPORT__ };
00164                         
00165                 }; // struct TimerCounter3
00166                 
00167         } // namespace Timer
00168         
00169 } // namespace AVRCpp
00170 
00171 #endif // ifndef __AVR_CPP_ATMEGA64_TIMER_H__

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