avr/cpp/at90usb1287/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_AT90USB1287_TIMER_H__
00029 #define __AVR_CPP_AT90USB1287_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/at90usb1287/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__ "at90usb1287/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 
00051 #define TIMER1_COMPA_ns Timer
00052 #define TIMER1_COMPB_ns Timer
00053 #define TIMER1_COMPC_ns Timer
00054 #define TIMER1_OVF_ns   Timer
00055 #define TIMER1_CAPT_ns  Timer
00056 
00057 #define TIMER2_COMPA_ns Timer
00058 #define TIMER2_COMPB_ns Timer
00059 #define TIMER2_OVF_ns   Timer
00060 
00061 #define TIMER3_COMPA_ns Timer
00062 #define TIMER3_COMPB_ns Timer
00063 #define TIMER3_COMPC_ns Timer
00064 #define TIMER3_OVF_ns   Timer
00065 #define TIMER3_CAPT_ns  Timer
00066 
00067 #define TIMER0_COMPA_struct     Timer::TimerCounter0::CompareMatchAInterrupt
00068 #define TIMER0_COMPB_struct     Timer::TimerCounter0::CompareMatchBInterrupt
00069 #define TIMER0_OVF_struct       Timer::TimerCounter0::OverflowInterrupt
00070 
00071 #define TIMER1_COMPA_struct Timer::TimerCounter1::CompareMatchAInterrupt
00072 #define TIMER1_COMPB_struct     Timer::TimerCounter1::CompareMatchBInterrupt
00073 #define TIMER1_COMPC_struct     Timer::TimerCounter1::CompareMatchCInterrupt
00074 #define TIMER1_OVF_struct       Timer::TimerCounter1::OverflowInterrupt
00075 #define TIMER1_CAPT_struct      Timer::TimerCounter1::InputCaptureInterrupt
00076 
00077 #define TIMER2_COMPA_struct     Timer::TimerCounter2::CompareMatchAInterrupt
00078 #define TIMER2_COMPB_struct     Timer::TimerCounter2::CompareMatchBInterrupt
00079 #define TIMER2_OVF_struct       Timer::TimerCounter2::OverflowInterrupt
00080 
00081 #define TIMER3_COMPA_struct Timer::TimerCounter3::CompareMatchAInterrupt
00082 #define TIMER3_COMPB_struct     Timer::TimerCounter3::CompareMatchBInterrupt
00083 #define TIMER3_COMPC_struct     Timer::TimerCounter3::CompareMatchCInterrupt
00084 #define TIMER3_OVF_struct       Timer::TimerCounter3::OverflowInterrupt
00085 #define TIMER3_CAPT_struct      Timer::TimerCounter3::InputCaptureInterrupt
00086 
00087 
00088 namespace AVRCpp
00089 {
00090         namespace Timer
00091         {
00092                 inline void StartSynchronization() { SetBits<_GTCCR>(_TSM); }
00093                 inline void EndSynchronization() { ClearBits<_GTCCR>(_TSM); }
00094                 
00095                 inline void PrescalerReset310() { SetBits<_GTCCR>(_PSRSYNC); }
00096                 inline void PrescalerReset2() { SetBits<_GTCCR>(_PSRASY); }
00097                 
00098                 
00099                 struct TimerCounter0 : Internal::TwoChannel8BitTimer <
00100                                 _TCNT0,                         /* CounterRegister */
00101                                 _OCR0A,                         /* OutputCompareRegisterA */
00102                                 _OCR0B,                         /* OutputCompareRegisterB */
00103                                 _TCCR0A,                        /* ControlRegisterA */
00104                                 _TCCR0B,                        /* ControlRegisterB */
00105                                 ClockB,                         /* ClockEnum */
00106                                 OutputPin7<PortB>,      /* ChannelAOutputPin */
00107                                 OutputPin0<PortD> >     /* ChannelBOutputPin */
00108                 {
00109                         struct CompareMatchAInterrupt : Interrupt<Bits<_TIMSK0, _OCIE0A>, Bits<_TIFR0, _OCF0A> > { __INTERRUPT_HANDLER_SUPPORT__ };
00110                         struct CompareMatchBInterrupt : Interrupt<Bits<_TIMSK0, _OCIE0B>, Bits<_TIFR0, _OCF0B> > { __INTERRUPT_HANDLER_SUPPORT__ };
00111                         struct OverflowInterrupt : Interrupt<Bits<_TIMSK0, _TOIE0>, Bits<_TIFR0, _TOV0> > { __INTERRUPT_HANDLER_SUPPORT__ };
00112                         
00113                 }; // struct TimerCounter0
00114                 
00115                 
00116                 struct TimerCounter1 : Internal::ThreeChannel16BitTimer <
00117                                 _TCNT1,                         /* CounterRegister */
00118                                 _OCR1A,                         /* OutputCompareRegisterA */
00119                                 _OCR1B,                         /* OutputCompareRegisterB */
00120                                 _OCR1C,                         /* OutputCompareRegisterC */
00121                                 _ICR1,                          /* InputCaptureRegister */
00122                                 _TCCR1A,                        /* ControlRegisterA */
00123                                 _TCCR1B,                        /* ControlRegisterB */
00124                                 _TCCR1C,                        /* ControlRegisterC */
00125                                 ClockB,                         /* ClockEnum */
00126                                 OutputPin5<PortB>,      /* ChannelAOutputPin */
00127                                 OutputPin6<PortB>,      /* ChannelBOutputPin */
00128                                 OutputPin7<PortB>,      /* ChannelCOutputPin */
00129                                 InputPin4<PortD> >      /* InputCaptureInputPin */
00130                 {
00131                         struct CompareMatchAInterrupt : Interrupt<Bits<_TIMSK1, _OCIE1A>, Bits<_TIFR1, _OCF1A> > { __INTERRUPT_HANDLER_SUPPORT__ };
00132                         struct CompareMatchBInterrupt : Interrupt<Bits<_TIMSK1, _OCIE1B>, Bits<_TIFR1, _OCF1B> > { __INTERRUPT_HANDLER_SUPPORT__ };
00133                         struct CompareMatchCInterrupt : Interrupt<Bits<_TIMSK1, _OCIE1C>, Bits<_TIFR1, _OCF1C> > { __INTERRUPT_HANDLER_SUPPORT__ };
00134                         struct OverflowInterrupt : Interrupt<Bits<_TIMSK1, _TOIE1>, Bits<_TIFR1, _TOV1> > { __INTERRUPT_HANDLER_SUPPORT__ };
00135                         struct InputCaptureInterrupt : Interrupt<Bits<_TIMSK1, _ICIE1>, Bits<_TIFR1, _ICF1> > { __INTERRUPT_HANDLER_SUPPORT__ };
00136                         
00137                 }; // struct TimerCounter1
00138                 
00139                 
00140                 struct TimerCounter2 : Internal::TwoChannel8BitTimerWithAsynchronousOperation <
00141                                 _TCNT2,                                 /* CounterRegister */
00142                                 _OCR2A,                                 /* OutputCompareRegisterA */
00143                                 _OCR2B,                                 /* OutputCompareRegisterB */
00144                                 _TCCR2A,                                /* ControlRegisterA */
00145                                 _TCCR2B,                                /* ControlRegisterB */
00146                                 _TIMSK2,                                /* InterruptMaskRegister */
00147                                 _TIFR2,                                 /* InterruptFlagRegister */
00148                                 _ASSR,                                  /* AsyncStatusRegister */
00149                                 OutputPin4<PortB>,              /* ChannelAOutputPin */
00150                                 OutputPin1<PortD> >             /* ChannelBOutputPin */
00151                 {
00152                         struct CompareMatchAInterrupt : Interrupt<Bits<_TIMSK2, _OCIE2A>, Bits<_TIFR2, _OCF2A> > { __INTERRUPT_HANDLER_SUPPORT__ };
00153                         struct CompareMatchBInterrupt : Interrupt<Bits<_TIMSK2, _OCIE2B>, Bits<_TIFR2, _OCF2B> > { __INTERRUPT_HANDLER_SUPPORT__ };
00154                         struct OverflowInterrupt : Interrupt<Bits<_TIMSK2, _TOIE2>, Bits<_TIFR2, _TOV2> > { __INTERRUPT_HANDLER_SUPPORT__ };
00155                         
00156                 }; // struct TimerCounter2
00157                 
00158                 
00159                 struct TimerCounter3 : Internal::ThreeChannel16BitTimer <
00160                                 _TCNT3,                         /* CounterRegister */
00161                                 _OCR3A,                         /* OutputCompareRegisterA */
00162                                 _OCR3B,                         /* OutputCompareRegisterB */
00163                                 _OCR3C,                         /* OutputCompareRegisterC */
00164                                 _ICR3,                          /* InputCaptureRegister */
00165                                 _TCCR3A,                        /* ControlRegisterA */
00166                                 _TCCR3B,                        /* ControlRegisterB */
00167                                 _TCCR3C,                        /* ControlRegisterC */
00168                                 ClockB,                         /* ClockEnum */
00169                                 OutputPin6<PortC>,      /* ChannelAOutputPin */
00170                                 OutputPin5<PortC>,      /* ChannelBOutputPin */
00171                                 OutputPin4<PortC>,      /* ChannelCOutputPin */
00172                                 InputPin7<PortC> >      /* InputCaptureInputPin */
00173                 {
00174                         struct CompareMatchAInterrupt : Interrupt<Bits<_TIMSK3, _OCIE3A>, Bits<_TIFR3, _OCF3A> > { __INTERRUPT_HANDLER_SUPPORT__ };
00175                         struct CompareMatchBInterrupt : Interrupt<Bits<_TIMSK3, _OCIE3B>, Bits<_TIFR3, _OCF3B> > { __INTERRUPT_HANDLER_SUPPORT__ };
00176                         struct CompareMatchCInterrupt : Interrupt<Bits<_TIMSK3, _OCIE3C>, Bits<_TIFR3, _OCF3C> > { __INTERRUPT_HANDLER_SUPPORT__ };
00177                         struct OverflowInterrupt : Interrupt<Bits<_TIMSK3, _TOIE3>, Bits<_TIFR3, _TOV3> > { __INTERRUPT_HANDLER_SUPPORT__ };
00178                         struct InputCaptureInterrupt : Interrupt<Bits<_TIMSK3, _ICIE3>, Bits<_TIFR3, _ICF3> > { __INTERRUPT_HANDLER_SUPPORT__ };
00179                         
00180                 }; // struct TimerCounter3
00181                 
00182         } // namespace Timer
00183         
00184 } // namespace AVRCpp
00185 
00186 #endif // ifndef __AVR_CPP_AT90USB1287_TIMER_H__

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