avr/cpp/atmega644/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_ATMEGA644_TIMER_H__
00029 #define __AVR_CPP_ATMEGA644_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/atmega644/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__ "atmega644/Timer.h"
00043 #else
00044 #error "Attempt to include more than one <avr/cpp/XXX/Timer.h> file."
00045 #endif
00046 
00047 #define TIMER0_COMPA_ns Timer
00048 #define TIMER0_COMPB_ns Timer
00049 #define TIMER0_OVF_ns   Timer
00050 #define TIMER1_OVF_ns   Timer
00051 #define TIMER1_COMPA_ns Timer
00052 #define TIMER1_COMPB_ns Timer
00053 #define TIMER1_CAPT_ns  Timer
00054 #define TIMER2_COMPA_ns Timer
00055 #define TIMER2_COMPB_ns Timer
00056 #define TIMER2_OVF_ns   Timer
00057 
00058 #define TIMER0_COMPA_struct     Timer::TimerCounter0::CompareMatchAInterrupt
00059 #define TIMER0_COMPB_struct     Timer::TimerCounter0::CompareMatchBInterrupt
00060 #define TIMER0_OVF_struct       Timer::TimerCounter0::OverflowInterrupt
00061 #define TIMER1_OVF_struct       Timer::TimerCounter1::OverflowInterrupt
00062 #define TIMER1_COMPA_struct     Timer::TimerCounter1::CompareMatchAInterrupt
00063 #define TIMER1_COMPB_struct     Timer::TimerCounter1::CompareMatchBInterrupt
00064 #define TIMER1_CAPT_struct      Timer::TimerCounter1::InputCaptureInterrupt
00065 #define TIMER2_COMPA_struct     Timer::TimerCounter2::CompareMatchAInterrupt
00066 #define TIMER2_COMPB_struct     Timer::TimerCounter2::CompareMatchBInterrupt
00067 #define TIMER2_OVF_struct       Timer::TimerCounter2::OverflowInterrupt
00068 
00069 
00070 namespace AVRCpp
00071 {
00072         namespace Timer
00073         {
00074                 
00075                 inline void StartSynchronization() { SetBits<_GTCCR>(_TSM); }
00076                 inline void EndSynchronization() { ClearBits<_GTCCR>(_TSM); }
00077                 
00078                 inline void PrescalerReset10() { SetBits<_GTCCR>(_PSRSYNC); }
00079                 
00080                 
00081                 struct TimerCounter0 : Internal::TwoChannel8BitTimer <
00082                                 _TCNT0,                         /* CounterRegister */
00083                                 _OCR0A,                         /* OutputCompareRegisterA */
00084                                 _OCR0B,                         /* OutputCompareRegisterB */
00085                                 _TCCR0A,                        /* ControlRegisterA */
00086                                 _TCCR0B,                        /* ControlRegisterB */
00087                                 ClockB,                         /* ClockEnum */
00088                                 OutputPin3<PortB>,      /* ChannelAOutputPin */
00089                                 OutputPin4<PortB> >     /* ChannelBOutputPin */
00090                 {
00091                         struct CompareMatchAInterrupt : Interrupt<Bits<_TIMSK0, _OCIE0A>, Bits<_TIFR0, _OCF0A> > { __INTERRUPT_HANDLER_SUPPORT__ };
00092                         struct CompareMatchBInterrupt : Interrupt<Bits<_TIMSK0, _OCIE0B>, Bits<_TIFR0, _OCF0B> > { __INTERRUPT_HANDLER_SUPPORT__ };
00093                         struct OverflowInterrupt : Interrupt<Bits<_TIMSK0, _TOIE0>, Bits<_TIFR0, _TOV0> > { __INTERRUPT_HANDLER_SUPPORT__ };
00094                         
00095                 }; // struct TimerCounter0
00096                 
00097                 
00098                 struct TimerCounter1 :  Internal::NewTwoChannel16BitTimer <
00099                                 _TCNT1,                         /* CounterRegister */
00100                                 _OCR1A,                         /* OutputCompareRegisterA */
00101                                 _OCR1B,                         /* OutputCompareRegisterB */
00102                                 _ICR1,                          /* InputCaptureRegister */
00103                                 _TCCR1A,                        /* ControlRegisterA */
00104                                 _TCCR1B,                        /* ControlRegisterB */
00105                                 _TCCR1C,                        /* ForceOutputCompare */
00106                                 ClockB,                         /* ClockEnum */
00107                                 OutputPin5<PortD>,      /* ChannelAOutputPin */
00108                                 OutputPin4<PortD>,      /* ChannelBOutputPin */
00109                                 InputPin6<PortD> >      /* InputCaptureInputPin */
00110                 {
00111                         struct InputCaptureInterrupt : Interrupt<Bits<_TIMSK1, _ICIE1>, Bits<_TIFR1, _ICF1> > { __INTERRUPT_HANDLER_SUPPORT__ };
00112                         struct CompareMatchAInterrupt : Interrupt<Bits<_TIMSK1, _OCIE1A>, Bits<_TIFR1, _OCF1A> > { __INTERRUPT_HANDLER_SUPPORT__ };
00113                         struct CompareMatchBInterrupt : Interrupt<Bits<_TIMSK1, _OCIE1B>, Bits<_TIFR1, _OCF1B> > { __INTERRUPT_HANDLER_SUPPORT__ };
00114                         struct OverflowInterrupt : Interrupt<Bits<_TIMSK1, _TOIE1>, Bits<_TIFR1, _TOV1> > { __INTERRUPT_HANDLER_SUPPORT__ };
00115                         
00116                 }; // struct TimerCounter1
00117                 
00118                 
00119                 struct TimerCounter2 : Internal::TwoChannel8BitTimerWithAsynchronousOperation <
00120                                 _TCNT2,                                 /* CounterRegister */
00121                                 _OCR2A,                                 /* OutputCompareRegisterA */
00122                                 _OCR2B,                                 /* OutputCompareRegisterB */
00123                                 _TCCR2A,                                /* ControlRegisterA */
00124                                 _TCCR2B,                                /* ControlRegisterB */
00125                                 _TIMSK2,                                /* InterruptMaskRegister */
00126                                 _TIFR2,                                 /* InterruptFlagRegister */
00127                                 _ASSR,                                  /* AsyncStatusRegister */
00128                                 OutputPin7<PortD>,              /* ChannelAOutputPin */
00129                                 OutputPin6<PortD> >             /* ChannelBOutputPin */
00130                 {
00131                         struct CompareMatchAInterrupt : Interrupt<Bits<_TIMSK2, _OCIE2A>, Bits<_TIFR2, _OCF2A> > { __INTERRUPT_HANDLER_SUPPORT__ };
00132                         struct CompareMatchBInterrupt : Interrupt<Bits<_TIMSK2, _OCIE2B>, Bits<_TIFR2, _OCF2B> > { __INTERRUPT_HANDLER_SUPPORT__ };
00133                         struct OverflowInterrupt : Interrupt<Bits<_TIMSK2, _TOIE2>, Bits<_TIFR2, _TOV2> > { __INTERRUPT_HANDLER_SUPPORT__ };
00134                         
00135                 }; // struct TimerCounter2
00136                 
00137         } // namespace Timer
00138         
00139 } // namespace AVRCpp
00140 
00141 #endif // ifndef __AVR_CPP_ATMEGA644_TIMER_H__

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