00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #if !defined(IOCOMPAT_H)
00015 #define IOCOMPAT_H 1
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #if defined(__AVR_AT90S2313__)
00026 # define OC1 PB3
00027 # define OCR OCR1
00028 # define DDROC DDRB
00029 # define TIMER1_OVF_vect TIMER1_OVF1_vect
00030 #elif defined(__AVR_AT90S2333__) || defined(__AVR_AT90S4433__)
00031 # define OC1 PB1
00032 # define DDROC DDRB
00033 # define OCR OCR1
00034 #elif defined(__AVR_AT90S4414__) || defined(__AVR_AT90S8515__) || \
00035 defined(__AVR_AT90S4434__) || defined(__AVR_AT90S8535__) || \
00036 defined(__AVR_ATmega163__) || defined(__AVR_ATmega8515__) || \
00037 defined(__AVR_ATmega8535__) || \
00038 defined(__AVR_ATmega164P__) || defined(__AVR_ATmega324P__) || \
00039 defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || \
00040 defined(__AVR_ATmega1284P__)
00041 # define OC1 PD5
00042 # define DDROC DDRD
00043 # define OCR OCR1A
00044 # if !defined(TIMSK)
00045 # define TIMSK TIMSK1
00046 # endif
00047 #elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega48__) || \
00048 defined(__AVR_ATmega88__) || defined(__AVR_ATmega168__)
00049 # define OC1 PB1
00050 # define DDROC DDRB
00051 # define OCR OCR1A
00052 # if !defined(TIMSK)
00053 # define TIMSK TIMSK1
00054 # endif
00055 #elif defined(__AVR_ATtiny2313__)
00056 # define OC1 PB3
00057 # define OCR OCR1A
00058 # define DDROC DDRB
00059 #elif defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || \
00060 defined(__AVR_ATtiny84__)
00061 # define OC1 PA6
00062 # define DDROC DDRA
00063 # if !defined(OCR1A)
00064 #
00065 # define OCR OCRA1
00066 # else
00067 # define OCR OCR1A
00068 # endif
00069 # define TIMSK TIMSK1
00070 # define TIMER1_OVF_vect TIM1_OVF_vect
00071 #elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || \
00072 defined(__AVR_ATtiny85__)
00073
00074 # define OC1 PB1
00075 # define DDROC DDRB
00076 # define OCR OCR1A
00077 # define TCCR1A TCCR1
00078 # define TCCR1B TCCR1
00079 # define TIMER1_OVF_vect TIM1_OVF_vect
00080 # define TIMER1_TOP 255
00081 # define TIMER1_PWM_INIT _BV(PWM1A) | _BV(COM1A1)
00082 # define TIMER1_CLOCKSOURCE _BV(CS12)
00083 #elif defined(__AVR_ATtiny26__)
00084
00085 # define OC1 PB1
00086 # define DDROC DDRB
00087 # define OCR OCR1A
00088 # define TIMER1_OVF_vect TIMER1_OVF1_vect
00089 # define TIMER1_TOP 255
00090 # define TIMER1_PWM_INIT _BV(PWM1A) | _BV(COM1A1)
00091 # define TIMER1_CLOCKSOURCE _BV(CS12)
00092
00093
00094
00095
00096 # define TIMER1_SETUP_HOOK() OCR1C = 255
00097 #elif defined(__AVR_ATtiny261__) || defined(__AVR_ATtiny461__) || \
00098 defined(__AVR_ATtiny861__)
00099 # define OC1 PB1
00100 # define DDROC DDRB
00101 # define OCR OCR1A
00102 # define TIMER1_PWM_INIT _BV(WGM10) | _BV(PWM1A) | _BV(COM1A1)
00103
00104
00105
00106
00107
00108
00109
00110 # define TIMER1_TOP 255
00111 # define TIMER1_CLOCKSOURCE _BV(CS12)
00112 #elif defined(__AVR_ATmega32__) || defined(__AVR_ATmega16__)
00113 # define OC1 PD5
00114 # define DDROC DDRD
00115 # define OCR OCR1A
00116 #elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) || \
00117 defined(__AVR_ATmega165__) || defined(__AVR_ATmega169__) || \
00118 defined(__AVR_ATmega325__) || defined(__AVR_ATmega3250__) || \
00119 defined(__AVR_ATmega645__) || defined(__AVR_ATmega6450__) || \
00120 defined(__AVR_ATmega329__) || defined(__AVR_ATmega3290__) || \
00121 defined(__AVR_ATmega649__) || defined(__AVR_ATmega6490__) || \
00122 defined(__AVR_ATmega640__) || \
00123 defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || \
00124 defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
00125 # define OC1 PB5
00126 # define DDROC DDRB
00127 # define OCR OCR1A
00128 # if !defined(PB5)
00129 # define PB5 5
00130 # endif
00131 # if !defined(TIMSK)
00132 # define TIMSK TIMSK1
00133 # endif
00134 #else
00135 # error "Don't know what kind of MCU you are compiling for"
00136 #endif
00137
00138
00139
00140
00141 #if !defined(COM1A1)
00142 # define COM1A1 COM11
00143 #endif
00144
00145 #if !defined(WGM10)
00146 # define WGM10 PWM10
00147 # define WGM11 PWM11
00148 #endif
00149
00150
00151
00152
00153
00154 #if !defined(TIMER1_TOP)
00155 # define TIMER1_TOP 1023
00156 #endif
00157
00158 #if !defined(TIMER1_PWM_INIT)
00159 # define TIMER1_PWM_INIT _BV(WGM10) | _BV(WGM11) | _BV(COM1A1)
00160 #endif
00161
00162 #if !defined(TIMER1_CLOCKSOURCE)
00163 # define TIMER1_CLOCKSOURCE _BV(CS10)
00164 #endif
00165
00166 #endif