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_ATMEGA8_TIMER_H__
00029 #define __AVR_CPP_ATMEGA8_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/atmega8/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__ "atmega8/Timer.h"
00043 #else
00044 #error "Attempt to include more than one <avr/cpp/XXX/Timer.h> file."
00045 #endif
00046
00047 #define TIMER0_OVF_ns Timer
00048 #define TIMER1_OVF_ns Timer
00049 #define TIMER1_COMPA_ns Timer
00050 #define TIMER1_COMPB_ns Timer
00051 #define TIMER1_CAPT_ns Timer
00052 #define TIMER2_COMP_ns Timer
00053 #define TIMER2_OVF_ns Timer
00054
00055 #define TIMER0_OVF_struct Timer::TimerCounter0::OverflowInterrupt
00056 #define TIMER1_OVF_struct Timer::TimerCounter1::OverflowInterrupt
00057 #define TIMER1_COMPA_struct Timer::TimerCounter1::CompareMatchAInterrupt
00058 #define TIMER1_COMPB_struct Timer::TimerCounter1::CompareMatchBInterrupt
00059 #define TIMER1_CAPT_struct Timer::TimerCounter1::InputCaptureInterrupt
00060 #define TIMER2_COMP_struct Timer::TimerCounter2::CompareMatchInterrupt
00061 #define TIMER2_OVF_struct Timer::TimerCounter2::OverflowInterrupt
00062
00063
00064 namespace AVRCpp
00065 {
00066 namespace Timer
00067 {
00068 inline void PrescalerReset10() { SetBits<_SFIOR>(_PSR10); }
00069 inline void PrescalerReset2() { SetBits<_SFIOR>(_PSR2); }
00070
00071
00072 struct TimerCounter0 : Internal::SimpleTimer <
00073 _TCNT0,
00074 _TCCR0,
00075 ClockB >
00076 {
00077 struct OverflowInterrupt : Interrupt<Bits<_TIMSK, _TOIE0>, Bits<_TIFR, _TOV0> > { __INTERRUPT_HANDLER_SUPPORT__ };
00078
00079 };
00080
00081
00082 struct TimerCounter1 : Internal::OldTwoChannel16BitTimer <
00083 _TCNT1,
00084 _OCR1A,
00085 _OCR1B,
00086 _ICR1,
00087 _TCCR1A,
00088 _TCCR1B,
00089 ClockB,
00090 OutputPin1<PortB>,
00091 OutputPin2<PortB>,
00092 InputPin0<PortB> >
00093 {
00094 struct InputCaptureInterrupt : Interrupt<Bits<_TIMSK, _TICIE1>, Bits<_TIFR, _ICF1> > { __INTERRUPT_HANDLER_SUPPORT__ };
00095 struct CompareMatchAInterrupt : Interrupt<Bits<_TIMSK, _OCIE1A>, Bits<_TIFR, _OCF1A> > { __INTERRUPT_HANDLER_SUPPORT__ };
00096 struct CompareMatchBInterrupt : Interrupt<Bits<_TIMSK, _OCIE1B>, Bits<_TIFR, _OCF1B> > { __INTERRUPT_HANDLER_SUPPORT__ };
00097 struct OverflowInterrupt : Interrupt<Bits<_TIMSK, _TOIE1>, Bits<_TIFR, _TOV1> > { __INTERRUPT_HANDLER_SUPPORT__ };
00098
00099 };
00100
00101
00102 struct TimerCounter2 : Internal::OneChannel8BitTimerWithAsynchronousOperation <
00103 _TCNT2,
00104 _OCR2,
00105 _TCCR2,
00106 _ASSR,
00107 Bits<_TIMSK, _OCIE2 | _TOIE2>,
00108 Bits<_TIFR, _OCF2 | _TOV2>,
00109 OutputPin3<PortB> >
00110 {
00111 struct CompareMatchInterrupt : Interrupt<Bits<_TIMSK, _OCIE2>, Bits<_TIFR, _OCF2> > { __INTERRUPT_HANDLER_SUPPORT__ };
00112 struct OverflowInterrupt : Interrupt<Bits<_TIMSK, _TOIE2>, Bits<_TIFR, _TOV2> > { __INTERRUPT_HANDLER_SUPPORT__ };
00113
00114 };
00115
00116 }
00117
00118 }
00119
00120 #endif // ifndef __AVR_CPP_ATMEGA8_TIMER_H__