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_ATMEGA644_TIMER_H__
00029 #define __AVR_CPP_ATMEGA644_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/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,
00083 _OCR0A,
00084 _OCR0B,
00085 _TCCR0A,
00086 _TCCR0B,
00087 ClockB,
00088 OutputPin3<PortB>,
00089 OutputPin4<PortB> >
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 };
00096
00097
00098 struct TimerCounter1 : Internal::NewTwoChannel16BitTimer <
00099 _TCNT1,
00100 _OCR1A,
00101 _OCR1B,
00102 _ICR1,
00103 _TCCR1A,
00104 _TCCR1B,
00105 _TCCR1C,
00106 ClockB,
00107 OutputPin5<PortD>,
00108 OutputPin4<PortD>,
00109 InputPin6<PortD> >
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 };
00117
00118
00119 struct TimerCounter2 : Internal::TwoChannel8BitTimerWithAsynchronousOperation <
00120 _TCNT2,
00121 _OCR2A,
00122 _OCR2B,
00123 _TCCR2A,
00124 _TCCR2B,
00125 _TIMSK2,
00126 _TIFR2,
00127 _ASSR,
00128 OutputPin7<PortD>,
00129 OutputPin6<PortD> >
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 };
00136
00137 }
00138
00139 }
00140
00141 #endif // ifndef __AVR_CPP_ATMEGA644_TIMER_H__