$treeview $search $mathjax $extrastylesheet
avr-libc
2.0.0
$projectbrief
|
$projectbrief
|
$searchbox |
AVR Libc Home Page |
AVR Libc Development Pages |
||||
Main Page |
User Manual |
Library Reference |
FAQ |
Example Projects |
00001 /* 00002 * ---------------------------------------------------------------------------- 00003 * "THE BEER-WARE LICENSE" (Revision 42): 00004 * <joerg@FreeBSD.ORG> wrote this file. As long as you retain this notice you 00005 * can do whatever you want with this stuff. If we meet some day, and you think 00006 * this stuff is worth it, you can buy me a beer in return. Joerg Wunsch 00007 * ---------------------------------------------------------------------------- 00008 * 00009 * IO feature compatibility definitions for various AVRs. 00010 * 00011 * $Id$ 00012 */ 00013 00014 #if !defined(IOCOMPAT_H) 00015 #define IOCOMPAT_H 1 00016 00017 /* 00018 * Device-specific adjustments: 00019 * 00020 * Supply definitions for the location of the OCR1[A] port/pin, the 00021 * name of the OCR register controlling the PWM, and adjust interrupt 00022 * vector names that differ from the one used in demo.c 00023 * [TIMER1_OVF_vect]. 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) /* new ATmegas */ 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) /* ATmega48/88/168 */ 00053 # define TIMSK TIMSK1 00054 # endif /* !defined(TIMSK) */ 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 # /* work around misspelled name in avr-libc 1.4.[0..1] */ 00065 # define OCR OCRA1 00066 # else 00067 # define OCR OCR1A 00068 # endif 00069 # define TIMSK TIMSK1 00070 # define TIMER1_OVF_vect TIM1_OVF_vect /* XML and datasheet mismatch */ 00071 #elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || \ 00072 defined(__AVR_ATtiny85__) 00073 /* Timer 1 is only an 8-bit timer on these devices. */ 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 /* only 8-bit PWM possible */ 00081 # define TIMER1_PWM_INIT _BV(PWM1A) | _BV(COM1A1) 00082 # define TIMER1_CLOCKSOURCE _BV(CS12) /* use 1/8 prescaler */ 00083 #elif defined(__AVR_ATtiny26__) 00084 /* Rather close to ATtinyX5 but different enough for its own section. */ 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 /* only 8-bit PWM possible */ 00090 # define TIMER1_PWM_INIT _BV(PWM1A) | _BV(COM1A1) 00091 # define TIMER1_CLOCKSOURCE _BV(CS12) /* use 1/8 prescaler */ 00092 /* 00093 * Without setting OCR1C to TOP, the ATtiny26 does not trigger an 00094 * overflow interrupt in PWM mode. 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 * While timer 1 could be operated in 10-bit mode on these devices, 00105 * the handling of the 10-bit IO registers is more complicated than 00106 * that of the 16-bit registers of other AVR devices (no combined 00107 * 16-bit IO operations possible), so we restrict this demo to 8-bit 00108 * mode which is pretty standard. 00109 */ 00110 # define TIMER1_TOP 255 00111 # define TIMER1_CLOCKSOURCE _BV(CS12) /* use 1/8 prescaler */ 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 defined(__AVR_ATmega32U4__) 00126 # define OC1 PB5 00127 # define DDROC DDRB 00128 # define OCR OCR1A 00129 # if !defined(PB5) /* work around missing bit definition */ 00130 # define PB5 5 00131 # endif 00132 # if !defined(TIMSK) /* new ATmegas */ 00133 # define TIMSK TIMSK1 00134 # endif 00135 #else 00136 # error "Don't know what kind of MCU you are compiling for" 00137 #endif 00138 00139 /* 00140 * Map register names for older AVRs here. 00141 */ 00142 #if !defined(COM1A1) 00143 # define COM1A1 COM11 00144 #endif 00145 00146 #if !defined(WGM10) 00147 # define WGM10 PWM10 00148 # define WGM11 PWM11 00149 #endif 00150 00151 /* 00152 * Provide defaults for device-specific macros unless overridden 00153 * above. 00154 */ 00155 #if !defined(TIMER1_TOP) 00156 # define TIMER1_TOP 1023 /* 10-bit PWM */ 00157 #endif 00158 00159 #if !defined(TIMER1_PWM_INIT) 00160 # define TIMER1_PWM_INIT _BV(WGM10) | _BV(WGM11) | _BV(COM1A1) 00161 #endif 00162 00163 #if !defined(TIMER1_CLOCKSOURCE) 00164 # define TIMER1_CLOCKSOURCE _BV(CS10) /* full clock */ 00165 #endif 00166 00167 #endif /* !defined(IOCOMPAT_H) */