00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef __AVR_CPP_ATMEGA64_TIMER_H__
00029 #define __AVR_CPP_ATMEGA64_TIMER_H__
00030
00031
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,
00094 _OCR0,
00095 _TCCR0,
00096 _ASSR,
00097 Bits<_TIMSK, _OCIE0 | _TOIE0>,
00098 Bits<_TIFR, _OCF0 | _TOV0>,
00099 OutputPin4<PortB> >
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 };
00105
00106
00107 struct TimerCounter1 : Internal::ThreeChannel16BitTimer <
00108 _TCNT1,
00109 _OCR1A,
00110 _OCR1B,
00111 _OCR1C,
00112 _ICR1,
00113 _TCCR1A,
00114 _TCCR1B,
00115 _TCCR1C,
00116 ClockB,
00117 OutputPin5<PortB>,
00118 OutputPin6<PortB>,
00119 OutputPin7<PortB>,
00120 InputPin4<PortD> >
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 };
00129
00130
00131 struct TimerCounter2 : Internal::OneChannel8BitTimer <
00132 _TCNT2,
00133 _OCR2,
00134 _TCCR2,
00135 ClockB,
00136 OutputPin7<PortB> >
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 };
00142
00143
00144 struct TimerCounter3 : Internal::ThreeChannel16BitTimer <
00145 _TCNT3,
00146 _OCR3A,
00147 _OCR3B,
00148 _OCR3C,
00149 _ICR3,
00150 _TCCR3A,
00151 _TCCR3B,
00152 _TCCR3C,
00153 ClockB,
00154 OutputPin3<PortE>,
00155 OutputPin4<PortE>,
00156 OutputPin5<PortE>,
00157 InputPin7<PortE> >
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 };
00166
00167 }
00168
00169 }
00170
00171 #endif // ifndef __AVR_CPP_ATMEGA64_TIMER_H__