7 #define _CONCAT_(x,y) x ## y 8 #define CONCAT(y,x) _CONCAT_(y,x) 11 #define DDR(x) CONCAT(DDR,x) 12 #define PORT(x) CONCAT(PORT,x) 13 #define PIN(x) CONCAT(PIN,x) 16 #define INIT(x) static void __attribute__((naked, used, section(".init" #x))) CONCAT(_init_, __COUNTER__) (void) 17 #define DONE(x) static void __attribute__((naked, used, section(".fini" #x))) CONCAT(_fini_, __COUNTER__) (void) 19 #define AUTOINIT() INIT(2) 20 #define MAIN() int __attribute__((OS_main)) main(void) 23 #define NOINIT __attribute__((section(".noinit"))) 34 #define ADC_DIV_2 _BV(ADPS0) 35 #define ADC_DIV_4 _BV(ADPS1) 36 #define ADC_DIV_8 (_BV(ADBP0) | _BV(ADPS1)) 37 #define ADC_DIV_16 _BV(ADPS2) 38 #define ADC_DIV_32 (_BV(ADPS0) | _BV(ADPS2)) 39 #define ADC_DIV_64 (_BV(ADPS2) | _BV(ADPS1)) 40 #define ADC_DIV_128 (_BV(ADPS0) | _BV(ADPS1) | _BV(ADPS2)) 44 #define ADC_TRIG_FRUN 0 45 #define ADC_TRIG_ACOMP _BV(ADTS0) 47 #define ADC_TRIG_INT0 _BV(ADTS1) 49 #define ADC_TRIG_T0_COMPA (_BV(ADTS0) | _BV(ADTS1)) 51 #define ADC_TRIG_T0_OVF _BV(ADTS2) 53 #define ADC_TRIG_T1_COMPB (_BV(ADTS2) | _BV(ADTS0)) 55 #define ADC_TRIG_T0_COMPB ADC_TRIG_T1_COMPB 57 #define ADC_TRIG_T1_OVF (_BV(ADTS2) | _BV(ADTS1)) 59 #define ADC_TRIG_PCI ADC_TRIG_T1_OVF 61 #define ADC_TRIG_T1_CAPTURE (_BV(ADTS2) | _BV(ADTS0) | _BV(ADTS1)) 74 #if defined(__AVR_ATmega88__) || defined(__AVR_ATmega48__) || defined(__AVR_ATmega168) 75 #define ADC_BANDGAP 15 79 #if defined(__AVR_ATmega128__) 80 #define ADC_0_DIF_0_G10 8 81 #define ADC_1_DIF_0_G10 9 82 #define ADC_0_DIF_0_G200 10 83 #define ADC_1_DIF_0_G200 11 84 #define ADC_2_DIF_2_G10 12 85 #define ADC_3_DIF_2_G10 13 86 #define ADC_2_DIF_2_G20 14 87 #define ADC_3_DIF_2_G200 15 88 #define ADC_0_DIF_1_G1 16 89 #define ADC_1_DIF_1_G1 17 90 #define ADC_2_DIF_1_G1 18 91 #define ADC_3_DIF_1_G1 19 92 #define ADC_4_DIF_1_G1 20 93 #define ADC_5_DIF_1_G1 21 94 #define ADC_6_DIF_1_G1 22 95 #define ADC_7_DIF_1_G1 23 96 #define ADC_0_DIF_2_G1 24 97 #define ADC_1_DIF_2_G1 25 98 #define ADC_2_DIF_2_G1 26 99 #define ADC_3_DIF_2_G1 27 100 #define ADC_4_DIF_2_G1 28 101 #define ADC_5_DIF_2_G1 29 102 #define ADC_BANDGAP 30 106 #if defined(__AVR_ATtiny26__) 107 #define ADC_REF_AVCC 0 108 #define ADC_REF_EXTERNAL _BV(REFS0) 109 #define ADC_REF_INT_NO_ECAP _BV(REFS1) 110 #define ADC_REF_INT_WITH_ECAP (_BV(REFS1) | _BV(REFS0)) 112 #define ADC_REF_EXTERNAL 0 113 #define ADC_REF_AVCC _BV(REFS0) 114 #define ADC_REF_INT_WITH_ECAP (_BV(REFS1) | _BV(REFS0)) 119 #define AC_INT_ON_TOGGLE 0 120 #define AC_INT_ON_FALLING _BV(ACIS1) 121 #define AC_INT_ON_RISING (_BV(ACIS1) | _BV(ACIS0)) 125 #define TIMER_CLK_DIV_1 1 126 #define TIMER_CLK_DIV_8 2 127 #define TIMER_CLK_DIV_64 3 128 #define TIMER_CLK_DIV_256 4 129 #define TIMER_CLK_DIV_1024 5 130 #define TIMER_CLK_EXT_FALL 6 131 #define TIMER_CLK_EXT_RISE 7 132 #define TIMER_CLK_DIV(x) CONCAT(TIMER_CLK_DIV_,x) 136 #define TIMER_OC_NONE(t) 0 137 #define TIMER_OC_TOGGLE(t) _BV(COM ## t ## 0) 138 #define TIMER_OC_CLEAR(t) _BV(COM ## t ## 1) 139 #define TIMER_OC_SET(t) _BV(COM ## t ## 0) | _BV(COM ## t ## 1) 143 #define EXINT_LOWLEVEL(i) 0 144 #define EXINT_CHANGE(i) _BV(ISC ## i ## 0) 145 #define EXINT_FALLING(i) _BV(ISC ## i ## 1) 146 #define EXINT_RISING(i) _BV(ISC ## i ## 0) | _BV(ISC ## i ## 1) 149 #define SPI_CLK_DIV_4 0 150 #define SPI_CLK_DIV_16 _BV(SPR0) 151 #define SPI_CLK_DIV_64 _BV(SPR1) 152 #define SPI_CLK_DIV_128 _BV(SPR0) | _BV(SPR1) 156 #define TWI_CLK_DIV_1 0 157 #define TWI_CLK_DIV_4 _BV(TWPS0) 158 #define TWI_CLK_DIV_16 _BV(TWPS1) 159 #define TWI_CLK_DIV_64 _BV(TWPS0) | _BV(TWPS1)