sketchbook
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
features.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2010-2015, Matthias Urlichs <matthias@urlichs.de>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License (included; see the file LICENSE)
13  * for more details.
14  */
15 
16 #ifndef FEATURES_H
17 #define FEATURES_H
18 
19 #include <avr/io.h>
20 #include <avr/interrupt.h>
21 
22 #include "dev_config.h"
23 
24 #ifdef MAIN
25 #define EXTERN
26 #define INIT(x) = x
27 #else
28 #define EXTERN extern
29 #define INIT(x)
30 #endif
31 
32 #ifndef BAUDRATE
33 #define BAUDRATE 38400
34 #endif
35 
36 /* External definitions:
37  * F_CPU clock rate
38  * SKIP_SEARCH if you don't have enough ROM for search (saves ~200 bytes)
39  * HAVE_UART if you want to debug your code
40  */
41 #ifdef __AVR_ATtiny13__
42 #define F_CPU_ 9600000
43 #define IMSK GIMSK
44 #define IFR GIFR
45 #endif
46 
47 #if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
48 #define F_CPU_ 8000000
49 #define IMSK GIMSK
50 #define IFR GIFR
51 #define TIMSK0 TIMSK
52 #define TIFR0 TIFR
53 
54 #define ADPIN PINB
55 #define ADPIN_vect PCINT0_vect
56 #define ADMSK PCMSK
57 #define PCIF0 PCIF
58 #define PCIE0 PCIE
59 #endif
60 
61 #ifdef __AVR_ATmega8__
62 #define F_CPU_ 8000000
63 #ifdef HAVE_DBG_PORT
64 #define DBGPORT PORTB
65 #define DBGDDR DDRB
66 #define DBGIN PINB
67 #endif
68 #ifdef HAVE_DBG_PIN
69 #define DBGPINPORT PORTD
70 #define DBGPIN PORTD4
71 #define DBGPINDDR DDRD
72 #define DBGPININ PIND
73 #endif
74 
75 #define IMSK GIMSK
76 #define TIMSK0 TIMSK
77 #define TIFR0 TIFR
78 #define EEPE EEWE
79 #define EEMPE EEMWE
80 #define IFR GIFR
81 #endif
82 
83 #ifdef __AVR_ATtiny84__
84 #define F_CPU_ 8000000
85 
86 #define IMSK GIMSK
87 #define IFR GIFR
88 #define ADPIN PINA
89 #define ADPIN_vect PCINT0_vect
90 #define ADMSK PCMSK0
91 #endif
92 
93 #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega88__) || defined (__AVR_ATmega328__)
94 #define F_CPU_ 16000000
95 #define ONEWIRE_USE_T2
96 
97 #ifdef HAVE_DBG_PORT
98 #define DBGPORT PORTC
99 #define DBGDDR DDRC
100 #define DBGIN PINC
101 #endif
102 #ifdef HAVE_DBG_PIN
103 #define DBGPINPORT PORTD
104 #define DBGPIN PORTD4
105 #define DBGPINDDR DDRD
106 #define DBGPININ PIND
107 #endif
108 
109 #define IMSK EIMSK
110 #define IFR EIFR
111 #define ADPIN PINC
112 #define ADPIN_vect PCINT1_vect
113 #define ADMSK PCMSK1
114 #define ADIRQ
115 
116 #endif
117 
118 #ifndef F_CPU_
119 #error Unknown AVR chip!
120 #endif
121 
122 #ifndef F_CPU
123 #define F_CPU F_CPU_
124 #endif
125 
126 #ifndef ONEWIRE_USE_T2
127 # define ONEWIRE_USE_T0
128 #endif
129 
130 #if defined(HAVE_UART_SYNC) && defined(HAVE_UART_IRQ)
131 #error Poll. Or IRQ. Not both.
132 #endif
133 
134 #if defined(IS_BOOTLOADER) && defined(USE_BOOTLOADER)
135 #error "Either you're a the loader or you're the loaded."
136 #endif
137 
138 #if defined(IS_BOOTLOADER) && !defined(USE_EEPROM)
139 #error "You need EEPROM support for bootloading"
140 #endif
141 
142 #define likely(x) __builtin_expect(!!(x), 1)
143 #define unlikely(x) __builtin_expect(!!(x), 0)
144 
145 #endif /* FEATURES_H */