Rev 1227 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1227 | Rev 1342 | ||
---|---|---|---|
1 | #-------------------------------------------------------------------- |
1 | #-------------------------------------------------------------------- |
2 | # MCU name |
2 | # MCU name |
3 | MCU = atmega644p |
3 | MCU = atmega644p |
4 | F_CPU = 20000000 |
4 | F_CPU = 20000000 |
5 | #------------------------------------------------------------------- |
5 | #------------------------------------------------------------------- |
6 | VERSION_MAJOR = 0 |
6 | VERSION_MAJOR = 0 |
7 | VERSION_MINOR = 74 |
7 | VERSION_MINOR = 74 |
8 | VERSION_PATCH = 3 |
8 | VERSION_PATCH = 3 |
9 | 9 | ||
10 | VERSION_SERIAL_MAJOR = 10 # Serial Protocol Major Version |
10 | VERSION_SERIAL_MAJOR = 10 # Serial Protocol Major Version |
11 | VERSION_SERIAL_MINOR = 1 # Serial Protocol Minor Version |
11 | VERSION_SERIAL_MINOR = 1 # Serial Protocol Minor Version |
12 | NC_SPI_COMPATIBLE = 6 # SPI Protocol Version |
12 | NC_SPI_COMPATIBLE = 6 # SPI Protocol Version |
13 | 13 | ||
14 | #------------------------------------------------------------------- |
14 | #------------------------------------------------------------------- |
15 | #OPTIONS |
15 | #OPTIONS |
16 | 16 | ||
17 | # Use one of the extensions for a gps solution |
17 | # Use one of the extensions for a gps solution |
18 | #EXT = KILLAGREG |
18 | #EXT = KILLAGREG |
19 | EXT = NAVICTRL |
19 | #EXT = NAVICTRL |
20 | #EXT = MK3MAG |
20 | EXT = MK3MAG |
21 | 21 | ||
22 | # Use optional one the RCs if EXT = NAVICTRL has been used |
22 | # Use optional one the RCs if EXT = NAVICTRL has been used |
23 | RC = DSL |
23 | #RC = DSL |
24 | #RC = SPECTRUM |
24 | #RC = SPECTRUM |
25 | 25 | ||
26 | #------------------------------------------------------------------- |
26 | #------------------------------------------------------------------- |
27 | # get SVN revision |
27 | # get SVN revision |
28 | REV := $(shell sh -c "cat .svn/entries | sed -n '4p'") |
28 | REV := $(shell sh -c "cat .svn/entries | sed -n '4p'") |
29 | 29 | ||
30 | ifeq ($(MCU), atmega644) |
30 | ifeq ($(MCU), atmega644) |
31 | FUSE_SETTINGS = -u -U lfuse:w:0xff:m -U hfuse:w:0xdf:m |
31 | FUSE_SETTINGS = -u -U lfuse:w:0xff:m -U hfuse:w:0xdf:m |
32 | HEX_NAME = MEGA644_$(EXT)_$(RC) |
32 | HEX_NAME = MEGA644_$(EXT)_$(RC) |
33 | endif |
33 | endif |
34 | 34 | ||
35 | ifeq ($(MCU), atmega644p) |
35 | ifeq ($(MCU), atmega644p) |
36 | FUSE_SETTINGS = -u -U lfuse:w:0xff:m -U hfuse:w:0xdf:m |
36 | FUSE_SETTINGS = -u -U lfuse:w:0xff:m -U hfuse:w:0xdf:m |
37 | HEX_NAME = MEGA644p_$(EXT)_$(RC) |
37 | HEX_NAME = MEGA644p_$(EXT)_$(RC) |
38 | endif |
38 | endif |
39 | 39 | ||
40 | 40 | ||
41 | ifeq ($(F_CPU), 16000000) |
41 | ifeq ($(F_CPU), 16000000) |
42 | QUARZ = 16MHZ |
42 | QUARZ = 16MHZ |
43 | endif |
43 | endif |
44 | 44 | ||
45 | ifeq ($(F_CPU), 20000000) |
45 | ifeq ($(F_CPU), 20000000) |
46 | QUARZ = 20MHZ |
46 | QUARZ = 20MHZ |
47 | endif |
47 | endif |
48 | 48 | ||
49 | 49 | ||
50 | # Output format. (can be srec, ihex, binary) |
50 | # Output format. (can be srec, ihex, binary) |
51 | FORMAT = ihex |
51 | FORMAT = ihex |
52 | 52 | ||
53 | # Target file name (without extension). |
53 | # Target file name (without extension). |
54 | 54 | ||
55 | ifeq ($(VERSION_PATCH), 0) |
55 | ifeq ($(VERSION_PATCH), 0) |
56 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)a_SVN$(REV) |
56 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)a_SVN$(REV) |
57 | endif |
57 | endif |
58 | ifeq ($(VERSION_PATCH), 1) |
58 | ifeq ($(VERSION_PATCH), 1) |
59 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)b_SVN$(REV) |
59 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)b_SVN$(REV) |
60 | endif |
60 | endif |
61 | ifeq ($(VERSION_PATCH), 2) |
61 | ifeq ($(VERSION_PATCH), 2) |
62 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)c_SVN$(REV) |
62 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)c_SVN$(REV) |
63 | endif |
63 | endif |
64 | ifeq ($(VERSION_PATCH), 3) |
64 | ifeq ($(VERSION_PATCH), 3) |
65 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)d_SVN$(REV) |
65 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)d_SVN$(REV) |
66 | endif |
66 | endif |
67 | ifeq ($(VERSION_PATCH), 4) |
67 | ifeq ($(VERSION_PATCH), 4) |
68 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)e_SVN$(REV) |
68 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)e_SVN$(REV) |
69 | endif |
69 | endif |
70 | ifeq ($(VERSION_PATCH), 5) |
70 | ifeq ($(VERSION_PATCH), 5) |
71 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)f_SVN$(REV) |
71 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)f_SVN$(REV) |
72 | endif |
72 | endif |
73 | ifeq ($(VERSION_PATCH), 6) |
73 | ifeq ($(VERSION_PATCH), 6) |
74 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)g_SVN$(REV) |
74 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)g_SVN$(REV) |
75 | endif |
75 | endif |
76 | ifeq ($(VERSION_PATCH), 7) |
76 | ifeq ($(VERSION_PATCH), 7) |
77 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)h_SVN$(REV) |
77 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)h_SVN$(REV) |
78 | endif |
78 | endif |
79 | ifeq ($(VERSION_PATCH), 8) |
79 | ifeq ($(VERSION_PATCH), 8) |
80 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)i_SVN$(REV) |
80 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)i_SVN$(REV) |
81 | endif |
81 | endif |
82 | ifeq ($(VERSION_PATCH), 9) |
82 | ifeq ($(VERSION_PATCH), 9) |
83 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)j_SVN$(REV) |
83 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)j_SVN$(REV) |
84 | endif |
84 | endif |
85 | ifeq ($(VERSION_PATCH), 10) |
85 | ifeq ($(VERSION_PATCH), 10) |
86 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)k_SVN$(REV) |
86 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)k_SVN$(REV) |
87 | endif |
87 | endif |
88 | ifeq ($(VERSION_PATCH), 11) |
88 | ifeq ($(VERSION_PATCH), 11) |
89 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)l_SVN$(REV) |
89 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)l_SVN$(REV) |
90 | endif |
90 | endif |
91 | ifeq ($(VERSION_PATCH), 12) |
91 | ifeq ($(VERSION_PATCH), 12) |
92 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)m_SVN$(REV) |
92 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)m_SVN$(REV) |
93 | endif |
93 | endif |
94 | ifeq ($(VERSION_PATCH), 13) |
94 | ifeq ($(VERSION_PATCH), 13) |
95 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)n_SVN$(REV) |
95 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)n_SVN$(REV) |
96 | endif |
96 | endif |
97 | ifeq ($(VERSION_PATCH), 14) |
97 | ifeq ($(VERSION_PATCH), 14) |
98 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)o_SVN$(REV) |
98 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)o_SVN$(REV) |
99 | endif |
99 | endif |
100 | ifeq ($(VERSION_PATCH), 15) |
100 | ifeq ($(VERSION_PATCH), 15) |
101 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)p_SVN$(REV) |
101 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)p_SVN$(REV) |
102 | endif |
102 | endif |
103 | ifeq ($(VERSION_PATCH), 16) |
103 | ifeq ($(VERSION_PATCH), 16) |
104 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)q_SVN$(REV) |
104 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)q_SVN$(REV) |
105 | endif |
105 | endif |
106 | ifeq ($(VERSION_PATCH), 17) |
106 | ifeq ($(VERSION_PATCH), 17) |
107 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)r_SVN$(REV) |
107 | TARGET = Flight-Ctrl_$(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)r_SVN$(REV) |
108 | endif |
108 | endif |
109 | 109 | ||
110 | # Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization. |
110 | # Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization. |
111 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
111 | # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
112 | OPT = 2 |
112 | OPT = 2 |
113 | #OPT = s |
113 | #OPT = s |
114 | 114 | ||
115 | ########################################################################################################## |
115 | ########################################################################################################## |
116 | # List C source files here. (C dependencies are automatically generated.) |
116 | # List C source files here. (C dependencies are automatically generated.) |
117 | SRC = main.c uart0.c printf_P.c timer0.c timer2.c analog.c menu.c led.c |
117 | SRC = main.c uart0.c printf_P.c timer0.c timer2.c analog.c menu.c led.c |
118 | SRC += twimaster.c rc.c fc.c eeprom.c uart1.c |
118 | SRC += twimaster.c rc.c fc.c eeprom.c uart1.c |
- | 119 | SRC += CapCalc.c |
|
119 | 120 | ||
120 | ifeq ($(EXT), KILLAGREG) |
121 | ifeq ($(EXT), KILLAGREG) |
121 | SRC += mm3.c mymath.c gps.c ubx.c |
122 | SRC += mm3.c mymath.c gps.c ubx.c |
122 | endif |
123 | endif |
123 | ifeq ($(EXT), MK3MAG) |
124 | ifeq ($(EXT), MK3MAG) |
124 | SRC += mk3mag.c mymath.c gps.c ubx.c |
125 | SRC += mk3mag.c mymath.c gps.c ubx.c |
125 | endif |
126 | endif |
126 | ifeq ($(EXT), NAVICTRL) |
127 | ifeq ($(EXT), NAVICTRL) |
127 | SRC += spi.c |
128 | SRC += spi.c |
128 | ifeq ($(RC), DSL) |
129 | ifeq ($(RC), DSL) |
129 | SRC += dsl.c |
130 | SRC += dsl.c |
130 | endif |
131 | endif |
131 | ifeq ($(RC), SPECTRUM) |
132 | ifeq ($(RC), SPECTRUM) |
132 | SRC += spectrum.c |
133 | SRC += spectrum.c |
133 | endif |
134 | endif |
134 | endif |
135 | endif |
135 | ########################################################################################################## |
136 | ########################################################################################################## |
136 | 137 | ||
137 | 138 | ||
138 | # List Assembler source files here. |
139 | # List Assembler source files here. |
139 | # Make them always end in a capital .S. Files ending in a lowercase .s |
140 | # Make them always end in a capital .S. Files ending in a lowercase .s |
140 | # will not be considered source files but generated files (assembler |
141 | # will not be considered source files but generated files (assembler |
141 | # output from the compiler), and will be deleted upon "make clean"! |
142 | # output from the compiler), and will be deleted upon "make clean"! |
142 | # Even though the DOS/Win* filesystem matches both .s and .S the same, |
143 | # Even though the DOS/Win* filesystem matches both .s and .S the same, |
143 | # it will preserve the spelling of the filenames, and gcc itself does |
144 | # it will preserve the spelling of the filenames, and gcc itself does |
144 | # care about how the name is spelled on its command-line. |
145 | # care about how the name is spelled on its command-line. |
145 | ASRC = |
146 | ASRC = |
146 | 147 | ||
147 | 148 | ||
148 | 149 | ||
149 | # List any extra directories to look for include files here. |
150 | # List any extra directories to look for include files here. |
150 | # Each directory must be seperated by a space. |
151 | # Each directory must be seperated by a space. |
151 | EXTRAINCDIRS = |
152 | EXTRAINCDIRS = |
152 | 153 | ||
153 | 154 | ||
154 | # Optional compiler flags. |
155 | # Optional compiler flags. |
155 | # -g: generate debugging information (for GDB, or for COFF conversion) |
156 | # -g: generate debugging information (for GDB, or for COFF conversion) |
156 | # -O*: optimization level |
157 | # -O*: optimization level |
157 | # -f...: tuning, see gcc manual and avr-libc documentation |
158 | # -f...: tuning, see gcc manual and avr-libc documentation |
158 | # -Wall...: warning level |
159 | # -Wall...: warning level |
159 | # -Wa,...: tell GCC to pass this to the assembler. |
160 | # -Wa,...: tell GCC to pass this to the assembler. |
160 | # -ahlms: create assembler listing |
161 | # -ahlms: create assembler listing |
161 | CFLAGS = -O$(OPT) \ |
162 | CFLAGS = -O$(OPT) \ |
162 | -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \ |
163 | -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \ |
163 | -Wall -Wstrict-prototypes \ |
164 | -Wall -Wstrict-prototypes \ |
164 | -Wa,-adhlns=$(<:.c=.lst) \ |
165 | -Wa,-adhlns=$(<:.c=.lst) \ |
165 | $(patsubst %,-I%,$(EXTRAINCDIRS)) |
166 | $(patsubst %,-I%,$(EXTRAINCDIRS)) |
166 | 167 | ||
167 | 168 | ||
168 | # Set a "language standard" compiler flag. |
169 | # Set a "language standard" compiler flag. |
169 | # Unremark just one line below to set the language standard to use. |
170 | # Unremark just one line below to set the language standard to use. |
170 | # gnu99 = C99 + GNU extensions. See GCC manual for more information. |
171 | # gnu99 = C99 + GNU extensions. See GCC manual for more information. |
171 | #CFLAGS += -std=c89 |
172 | #CFLAGS += -std=c89 |
172 | #CFLAGS += -std=gnu89 |
173 | #CFLAGS += -std=gnu89 |
173 | #CFLAGS += -std=c99 |
174 | #CFLAGS += -std=c99 |
174 | CFLAGS += -std=gnu99 |
175 | CFLAGS += -std=gnu99 |
175 | 176 | ||
176 | CFLAGS += -DF_CPU=$(F_CPU) -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_PATCH=$(VERSION_PATCH) -DVERSION_SERIAL_MAJOR=$(VERSION_SERIAL_MAJOR) -DVERSION_SERIAL_MINOR=$(VERSION_SERIAL_MINOR) -DNC_SPI_COMPATIBLE=$(NC_SPI_COMPATIBLE) |
177 | CFLAGS += -DF_CPU=$(F_CPU) -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_PATCH=$(VERSION_PATCH) -DVERSION_SERIAL_MAJOR=$(VERSION_SERIAL_MAJOR) -DVERSION_SERIAL_MINOR=$(VERSION_SERIAL_MINOR) -DNC_SPI_COMPATIBLE=$(NC_SPI_COMPATIBLE) |
177 | 178 | ||
178 | ifeq ($(EXT), KILLAGREG) |
179 | ifeq ($(EXT), KILLAGREG) |
179 | CFLAGS += -DUSE_KILLAGREG |
180 | CFLAGS += -DUSE_KILLAGREG |
180 | endif |
181 | endif |
181 | ifeq ($(EXT), MK3MAG) |
182 | ifeq ($(EXT), MK3MAG) |
182 | CFLAGS += -DUSE_MK3MAG |
183 | CFLAGS += -DUSE_MK3MAG |
183 | endif |
184 | endif |
184 | ifeq ($(EXT), NAVICTRL) |
185 | ifeq ($(EXT), NAVICTRL) |
185 | CFLAGS += -DUSE_NAVICTRL |
186 | CFLAGS += -DUSE_NAVICTRL |
186 | ifeq ($(RC), DSL) |
187 | ifeq ($(RC), DSL) |
187 | CFLAGS += -DUSE_RC_DSL |
188 | CFLAGS += -DUSE_RC_DSL |
188 | endif |
189 | endif |
189 | ifeq ($(RC), SPECTRUM) |
190 | ifeq ($(RC), SPECTRUM) |
190 | CFLAGS += -DUSE_RC_SPECTRUM |
191 | CFLAGS += -DUSE_RC_SPECTRUM |
191 | endif |
192 | endif |
192 | endif |
193 | endif |
193 | 194 | ||
194 | ifeq ($(SETUP), QUADRO) |
195 | ifeq ($(SETUP), QUADRO) |
195 | CFLAGS += -DUSE_QUADRO |
196 | CFLAGS += -DUSE_QUADRO |
196 | endif |
197 | endif |
197 | ifeq ($(SETUP), OCTO) |
198 | ifeq ($(SETUP), OCTO) |
198 | CFLAGS += -DUSE_OCTO |
199 | CFLAGS += -DUSE_OCTO |
199 | endif |
200 | endif |
200 | ifeq ($(SETUP), OCTO2) |
201 | ifeq ($(SETUP), OCTO2) |
201 | CFLAGS += -DUSE_OCTO2 |
202 | CFLAGS += -DUSE_OCTO2 |
202 | endif |
203 | endif |
203 | ifeq ($(SETUP), OCTO3) |
204 | ifeq ($(SETUP), OCTO3) |
204 | CFLAGS += -DUSE_OCTO3 |
205 | CFLAGS += -DUSE_OCTO3 |
205 | endif |
206 | endif |
206 | 207 | ||
207 | 208 | ||
208 | 209 | ||
209 | 210 | ||
210 | # Optional assembler flags. |
211 | # Optional assembler flags. |
211 | # -Wa,...: tell GCC to pass this to the assembler. |
212 | # -Wa,...: tell GCC to pass this to the assembler. |
212 | # -ahlms: create listing |
213 | # -ahlms: create listing |
213 | # -gstabs: have the assembler create line number information; note that |
214 | # -gstabs: have the assembler create line number information; note that |
214 | # for use in COFF files, additional information about filenames |
215 | # for use in COFF files, additional information about filenames |
215 | # and function names needs to be present in the assembler source |
216 | # and function names needs to be present in the assembler source |
216 | # files -- see avr-libc docs [FIXME: not yet described there] |
217 | # files -- see avr-libc docs [FIXME: not yet described there] |
217 | ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
218 | ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
218 | 219 | ||
219 | 220 | ||
220 | 221 | ||
221 | # Optional linker flags. |
222 | # Optional linker flags. |
222 | # -Wl,...: tell GCC to pass this to linker. |
223 | # -Wl,...: tell GCC to pass this to linker. |
223 | # -Map: create map file |
224 | # -Map: create map file |
224 | # --cref: add cross reference to map file |
225 | # --cref: add cross reference to map file |
225 | LDFLAGS = -Wl,-Map=$(TARGET).map,--cref |
226 | LDFLAGS = -Wl,-Map=$(TARGET).map,--cref |
226 | 227 | ||
227 | # Additional libraries |
228 | # Additional libraries |
228 | 229 | ||
229 | # Minimalistic printf version |
230 | # Minimalistic printf version |
230 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_min |
231 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_min |
231 | 232 | ||
232 | # Floating point printf version (requires -lm below) |
233 | # Floating point printf version (requires -lm below) |
233 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt |
234 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt |
234 | 235 | ||
235 | # -lm = math library |
236 | # -lm = math library |
236 | LDFLAGS += -lm |
237 | LDFLAGS += -lm |
237 | 238 | ||
238 | 239 | ||
239 | ##LDFLAGS += -T./linkerfile/avr5.x |
240 | ##LDFLAGS += -T./linkerfile/avr5.x |
240 | 241 | ||
241 | 242 | ||
242 | 243 | ||
243 | # Programming support using avrdude. Settings and variables. |
244 | # Programming support using avrdude. Settings and variables. |
244 | 245 | ||
245 | # Programming hardware: alf avr910 avrisp bascom bsd |
246 | # Programming hardware: alf avr910 avrisp bascom bsd |
246 | # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 |
247 | # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 |
247 | # |
248 | # |
248 | # Type: avrdude -c ? |
249 | # Type: avrdude -c ? |
249 | # to get a full listing. |
250 | # to get a full listing. |
250 | # |
251 | # |
251 | #AVRDUDE_PROGRAMMER = dt006 |
252 | #AVRDUDE_PROGRAMMER = dt006 |
252 | #AVRDUDE_PROGRAMMER = stk200 |
253 | #AVRDUDE_PROGRAMMER = stk200 |
253 | #AVRDUDE_PROGRAMMER = ponyser |
254 | #AVRDUDE_PROGRAMMER = ponyser |
254 | AVRDUDE_PROGRAMMER = avrispv2 |
255 | AVRDUDE_PROGRAMMER = avrispv2 |
255 | #falls Ponyser ausgewählt wird, muss sich unsere avrdude-Configdatei im Bin-Verzeichnis des Compilers befinden |
256 | #falls Ponyser ausgewählt wird, muss sich unsere avrdude-Configdatei im Bin-Verzeichnis des Compilers befinden |
256 | 257 | ||
257 | #AVRDUDE_PORT = com1 # programmer connected to serial device |
258 | #AVRDUDE_PORT = com1 # programmer connected to serial device |
258 | #AVRDUDE_PORT = lpt1 # programmer connected to parallel port |
259 | #AVRDUDE_PORT = lpt1 # programmer connected to parallel port |
259 | AVRDUDE_PORT = usb # programmer connected to USB |
260 | AVRDUDE_PORT = usb # programmer connected to USB |
260 | 261 | ||
261 | #AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex |
262 | #AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex |
262 | AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex $(FUSE_SETTINGS) |
263 | AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex $(FUSE_SETTINGS) |
263 | #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep |
264 | #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep |
264 | 265 | ||
265 | #avrdude -c avrispv2 -P usb -p m32 -U flash:w:blink.hex |
266 | #avrdude -c avrispv2 -P usb -p m32 -U flash:w:blink.hex |
266 | AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) |
267 | AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) |
267 | 268 | ||
268 | # Uncomment the following if you want avrdude's erase cycle counter. |
269 | # Uncomment the following if you want avrdude's erase cycle counter. |
269 | # Note that this counter needs to be initialized first using -Yn, |
270 | # Note that this counter needs to be initialized first using -Yn, |
270 | # see avrdude manual. |
271 | # see avrdude manual. |
271 | #AVRDUDE_ERASE += -y |
272 | #AVRDUDE_ERASE += -y |
272 | 273 | ||
273 | # Uncomment the following if you do /not/ wish a verification to be |
274 | # Uncomment the following if you do /not/ wish a verification to be |
274 | # performed after programming the device. |
275 | # performed after programming the device. |
275 | AVRDUDE_FLAGS += -V |
276 | AVRDUDE_FLAGS += -V |
276 | 277 | ||
277 | # Increase verbosity level. Please use this when submitting bug |
278 | # Increase verbosity level. Please use this when submitting bug |
278 | # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> |
279 | # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> |
279 | # to submit bug reports. |
280 | # to submit bug reports. |
280 | #AVRDUDE_FLAGS += -v -v |
281 | #AVRDUDE_FLAGS += -v -v |
281 | 282 | ||
282 | # --------------------------------------------------------------------------- |
283 | # --------------------------------------------------------------------------- |
283 | # Define directories, if needed. |
284 | # Define directories, if needed. |
284 | DIRAVR = c:/winavr |
285 | DIRAVR = c:/winavr |
285 | DIRAVRBIN = $(DIRAVR)/bin |
286 | DIRAVRBIN = $(DIRAVR)/bin |
286 | DIRAVRUTILS = $(DIRAVR)/utils/bin |
287 | DIRAVRUTILS = $(DIRAVR)/utils/bin |
287 | DIRINC = . |
288 | DIRINC = . |
288 | DIRLIB = $(DIRAVR)/avr/lib |
289 | DIRLIB = $(DIRAVR)/avr/lib |
289 | 290 | ||
290 | 291 | ||
291 | # Define programs and commands. |
292 | # Define programs and commands. |
292 | SHELL = sh |
293 | SHELL = sh |
293 | 294 | ||
294 | CC = avr-gcc |
295 | CC = avr-gcc |
295 | 296 | ||
296 | OBJCOPY = avr-objcopy |
297 | OBJCOPY = avr-objcopy |
297 | OBJDUMP = avr-objdump |
298 | OBJDUMP = avr-objdump |
298 | SIZE = avr-size |
299 | SIZE = avr-size |
299 | 300 | ||
300 | # Programming support using avrdude. |
301 | # Programming support using avrdude. |
301 | AVRDUDE = avrdude |
302 | AVRDUDE = avrdude |
302 | 303 | ||
303 | REMOVE = rm -f |
304 | REMOVE = rm -f |
304 | COPY = cp |
305 | COPY = cp |
305 | 306 | ||
306 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex |
307 | HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex |
307 | ELFSIZE = $(SIZE) -A $(TARGET).elf |
308 | ELFSIZE = $(SIZE) -A $(TARGET).elf |
308 | 309 | ||
309 | # Define Messages |
310 | # Define Messages |
310 | # English |
311 | # English |
311 | MSG_ERRORS_NONE = Errors: none |
312 | MSG_ERRORS_NONE = Errors: none |
312 | MSG_BEGIN = -------- begin -------- |
313 | MSG_BEGIN = -------- begin -------- |
313 | MSG_END = -------- end -------- |
314 | MSG_END = -------- end -------- |
314 | MSG_SIZE_BEFORE = Size before: |
315 | MSG_SIZE_BEFORE = Size before: |
315 | MSG_SIZE_AFTER = Size after: |
316 | MSG_SIZE_AFTER = Size after: |
316 | MSG_COFF = Converting to AVR COFF: |
317 | MSG_COFF = Converting to AVR COFF: |
317 | MSG_EXTENDED_COFF = Converting to AVR Extended COFF: |
318 | MSG_EXTENDED_COFF = Converting to AVR Extended COFF: |
318 | MSG_FLASH = Creating load file for Flash: |
319 | MSG_FLASH = Creating load file for Flash: |
319 | MSG_EEPROM = Creating load file for EEPROM: |
320 | MSG_EEPROM = Creating load file for EEPROM: |
320 | MSG_EXTENDED_LISTING = Creating Extended Listing: |
321 | MSG_EXTENDED_LISTING = Creating Extended Listing: |
321 | MSG_SYMBOL_TABLE = Creating Symbol Table: |
322 | MSG_SYMBOL_TABLE = Creating Symbol Table: |
322 | MSG_LINKING = Linking: |
323 | MSG_LINKING = Linking: |
323 | MSG_COMPILING = Compiling: |
324 | MSG_COMPILING = Compiling: |
324 | MSG_ASSEMBLING = Assembling: |
325 | MSG_ASSEMBLING = Assembling: |
325 | MSG_CLEANING = Cleaning project: |
326 | MSG_CLEANING = Cleaning project: |
326 | 327 | ||
327 | 328 | ||
328 | # Define all object files. |
329 | # Define all object files. |
329 | OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) |
330 | OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) |
330 | 331 | ||
331 | # Define all listing files. |
332 | # Define all listing files. |
332 | LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) |
333 | LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) |
333 | 334 | ||
334 | # Combine all necessary flags and optional flags. |
335 | # Combine all necessary flags and optional flags. |
335 | # Add target processor to flags. |
336 | # Add target processor to flags. |
336 | #ALL_CFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -I. $(CFLAGS) |
337 | #ALL_CFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -I. $(CFLAGS) |
337 | ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) |
338 | ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) |
338 | ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) |
339 | ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) |
339 | 340 | ||
340 | 341 | ||
341 | # Default target. |
342 | # Default target. |
342 | all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \ |
343 | all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \ |
343 | $(TARGET).lss $(TARGET).sym sizeafter finished end |
344 | $(TARGET).lss $(TARGET).sym sizeafter finished end |
344 | 345 | ||
345 | 346 | ||
346 | # Eye candy. |
347 | # Eye candy. |
347 | # AVR Studio 3.x does not check make's exit code but relies on |
348 | # AVR Studio 3.x does not check make's exit code but relies on |
348 | # the following magic strings to be generated by the compile job. |
349 | # the following magic strings to be generated by the compile job. |
349 | begin: |
350 | begin: |
350 | @echo |
351 | @echo |
351 | @echo $(MSG_BEGIN) |
352 | @echo $(MSG_BEGIN) |
352 | 353 | ||
353 | finished: |
354 | finished: |
354 | @echo $(MSG_ERRORS_NONE) |
355 | @echo $(MSG_ERRORS_NONE) |
355 | 356 | ||
356 | end: |
357 | end: |
357 | @echo $(MSG_END) |
358 | @echo $(MSG_END) |
358 | @echo |
359 | @echo |
359 | 360 | ||
360 | 361 | ||
361 | # Display size of file. |
362 | # Display size of file. |
362 | sizebefore: |
363 | sizebefore: |
363 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi |
364 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi |
364 | 365 | ||
365 | sizeafter: |
366 | sizeafter: |
366 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi |
367 | @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi |
367 | 368 | ||
368 | 369 | ||
369 | 370 | ||
370 | # Display compiler version information. |
371 | # Display compiler version information. |
371 | gccversion : |
372 | gccversion : |
372 | @$(CC) --version |
373 | @$(CC) --version |
373 | 374 | ||
374 | 375 | ||
375 | # Convert ELF to COFF for use in debugging / simulating in |
376 | # Convert ELF to COFF for use in debugging / simulating in |
376 | # AVR Studio or VMLAB. |
377 | # AVR Studio or VMLAB. |
377 | COFFCONVERT=$(OBJCOPY) --debugging \ |
378 | COFFCONVERT=$(OBJCOPY) --debugging \ |
378 | --change-section-address .data-0x800000 \ |
379 | --change-section-address .data-0x800000 \ |
379 | --change-section-address .bss-0x800000 \ |
380 | --change-section-address .bss-0x800000 \ |
380 | --change-section-address .noinit-0x800000 \ |
381 | --change-section-address .noinit-0x800000 \ |
381 | --change-section-address .eeprom-0x810000 |
382 | --change-section-address .eeprom-0x810000 |
382 | 383 | ||
383 | 384 | ||
384 | coff: $(TARGET).elf |
385 | coff: $(TARGET).elf |
385 | @echo |
386 | @echo |
386 | @echo $(MSG_COFF) $(TARGET).cof |
387 | @echo $(MSG_COFF) $(TARGET).cof |
387 | $(COFFCONVERT) -O coff-avr $< $(TARGET).cof |
388 | $(COFFCONVERT) -O coff-avr $< $(TARGET).cof |
388 | 389 | ||
389 | 390 | ||
390 | extcoff: $(TARGET).elf |
391 | extcoff: $(TARGET).elf |
391 | @echo |
392 | @echo |
392 | @echo $(MSG_EXTENDED_COFF) $(TARGET).cof |
393 | @echo $(MSG_EXTENDED_COFF) $(TARGET).cof |
393 | $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof |
394 | $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof |
394 | 395 | ||
395 | 396 | ||
396 | 397 | ||
397 | 398 | ||
398 | # Program the device. |
399 | # Program the device. |
399 | program: $(TARGET).hex $(TARGET).eep |
400 | program: $(TARGET).hex $(TARGET).eep |
400 | $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) |
401 | $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) |
401 | 402 | ||
402 | 403 | ||
403 | 404 | ||
404 | 405 | ||
405 | # Create final output files (.hex, .eep) from ELF output file. |
406 | # Create final output files (.hex, .eep) from ELF output file. |
406 | %.hex: %.elf |
407 | %.hex: %.elf |
407 | @echo |
408 | @echo |
408 | @echo $(MSG_FLASH) $@ |
409 | @echo $(MSG_FLASH) $@ |
409 | $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ |
410 | $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ |
410 | 411 | ||
411 | %.eep: %.elf |
412 | %.eep: %.elf |
412 | @echo |
413 | @echo |
413 | @echo $(MSG_EEPROM) $@ |
414 | @echo $(MSG_EEPROM) $@ |
414 | -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ |
415 | -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ |
415 | --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ |
416 | --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ |
416 | 417 | ||
417 | # Create extended listing file from ELF output file. |
418 | # Create extended listing file from ELF output file. |
418 | %.lss: %.elf |
419 | %.lss: %.elf |
419 | @echo |
420 | @echo |
420 | @echo $(MSG_EXTENDED_LISTING) $@ |
421 | @echo $(MSG_EXTENDED_LISTING) $@ |
421 | $(OBJDUMP) -h -S $< > $@ |
422 | $(OBJDUMP) -h -S $< > $@ |
422 | 423 | ||
423 | # Create a symbol table from ELF output file. |
424 | # Create a symbol table from ELF output file. |
424 | %.sym: %.elf |
425 | %.sym: %.elf |
425 | @echo |
426 | @echo |
426 | @echo $(MSG_SYMBOL_TABLE) $@ |
427 | @echo $(MSG_SYMBOL_TABLE) $@ |
427 | avr-nm -n $< > $@ |
428 | avr-nm -n $< > $@ |
428 | 429 | ||
429 | 430 | ||
430 | 431 | ||
431 | # Link: create ELF output file from object files. |
432 | # Link: create ELF output file from object files. |
432 | .SECONDARY : $(TARGET).elf |
433 | .SECONDARY : $(TARGET).elf |
433 | .PRECIOUS : $(OBJ) |
434 | .PRECIOUS : $(OBJ) |
434 | %.elf: $(OBJ) |
435 | %.elf: $(OBJ) |
435 | @echo |
436 | @echo |
436 | @echo $(MSG_LINKING) $@ |
437 | @echo $(MSG_LINKING) $@ |
437 | $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) |
438 | $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) |
438 | 439 | ||
439 | 440 | ||
440 | # Compile: create object files from C source files. |
441 | # Compile: create object files from C source files. |
441 | %.o : %.c |
442 | %.o : %.c |
442 | @echo |
443 | @echo |
443 | @echo $(MSG_COMPILING) $< |
444 | @echo $(MSG_COMPILING) $< |
444 | $(CC) -c $(ALL_CFLAGS) $< -o $@ |
445 | $(CC) -c $(ALL_CFLAGS) $< -o $@ |
445 | 446 | ||
446 | 447 | ||
447 | # Compile: create assembler files from C source files. |
448 | # Compile: create assembler files from C source files. |
448 | %.s : %.c |
449 | %.s : %.c |
449 | $(CC) -S $(ALL_CFLAGS) $< -o $@ |
450 | $(CC) -S $(ALL_CFLAGS) $< -o $@ |
450 | 451 | ||
451 | 452 | ||
452 | # Assemble: create object files from assembler source files. |
453 | # Assemble: create object files from assembler source files. |
453 | %.o : %.S |
454 | %.o : %.S |
454 | @echo |
455 | @echo |
455 | @echo $(MSG_ASSEMBLING) $< |
456 | @echo $(MSG_ASSEMBLING) $< |
456 | $(CC) -c $(ALL_ASFLAGS) $< -o $@ |
457 | $(CC) -c $(ALL_ASFLAGS) $< -o $@ |
457 | 458 | ||
458 | 459 | ||
459 | 460 | ||
460 | 461 | ||
461 | 462 | ||
462 | 463 | ||
463 | # Target: clean project. |
464 | # Target: clean project. |
464 | clean: begin clean_list finished end |
465 | clean: begin clean_list finished end |
465 | 466 | ||
466 | clean_list : |
467 | clean_list : |
467 | @echo |
468 | @echo |
468 | @echo $(MSG_CLEANING) |
469 | @echo $(MSG_CLEANING) |
469 | # $(REMOVE) $(TARGET).hex |
470 | # $(REMOVE) $(TARGET).hex |
470 | $(REMOVE) $(TARGET).eep |
471 | $(REMOVE) $(TARGET).eep |
471 | $(REMOVE) $(TARGET).obj |
472 | $(REMOVE) $(TARGET).obj |
472 | $(REMOVE) $(TARGET).cof |
473 | $(REMOVE) $(TARGET).cof |
473 | $(REMOVE) $(TARGET).elf |
474 | $(REMOVE) $(TARGET).elf |
474 | $(REMOVE) $(TARGET).map |
475 | $(REMOVE) $(TARGET).map |
475 | $(REMOVE) $(TARGET).obj |
476 | $(REMOVE) $(TARGET).obj |
476 | $(REMOVE) $(TARGET).a90 |
477 | $(REMOVE) $(TARGET).a90 |
477 | $(REMOVE) $(TARGET).sym |
478 | $(REMOVE) $(TARGET).sym |
478 | $(REMOVE) $(TARGET).lnk |
479 | $(REMOVE) $(TARGET).lnk |
479 | $(REMOVE) $(TARGET).lss |
480 | $(REMOVE) $(TARGET).lss |
480 | $(REMOVE) $(OBJ) |
481 | $(REMOVE) $(OBJ) |
481 | $(REMOVE) $(LST) |
482 | $(REMOVE) $(LST) |
482 | $(REMOVE) $(SRC:.c=.s) |
483 | $(REMOVE) $(SRC:.c=.s) |
483 | $(REMOVE) $(SRC:.c=.d) |
484 | $(REMOVE) $(SRC:.c=.d) |
484 | 485 | ||
485 | 486 | ||
486 | # Automatically generate C source code dependencies. |
487 | # Automatically generate C source code dependencies. |
487 | # (Code originally taken from the GNU make user manual and modified |
488 | # (Code originally taken from the GNU make user manual and modified |
488 | # (See README.txt Credits).) |
489 | # (See README.txt Credits).) |
489 | # |
490 | # |
490 | # Note that this will work with sh (bash) and sed that is shipped with WinAVR |
491 | # Note that this will work with sh (bash) and sed that is shipped with WinAVR |
491 | # (see the SHELL variable defined above). |
492 | # (see the SHELL variable defined above). |
492 | # This may not work with other shells or other seds. |
493 | # This may not work with other shells or other seds. |
493 | # |
494 | # |
494 | %.d: %.c |
495 | %.d: %.c |
495 | set -e; $(CC) -MM $(ALL_CFLAGS) $< \ |
496 | set -e; $(CC) -MM $(ALL_CFLAGS) $< \ |
496 | | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \ |
497 | | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \ |
497 | [ -s $@ ] || rm -f $@ |
498 | [ -s $@ ] || rm -f $@ |
498 | 499 | ||
499 | 500 | ||
500 | # Remove the '-' if you want to see the dependency files generated. |
501 | # Remove the '-' if you want to see the dependency files generated. |
501 | -include $(SRC:.c=.d) |
502 | -include $(SRC:.c=.d) |
502 | 503 | ||
503 | 504 | ||
504 | 505 | ||
505 | # Listing of phony targets. |
506 | # Listing of phony targets. |
506 | .PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \ |
507 | .PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \ |
507 | clean clean_list program |
508 | clean clean_list program |
508 | 509 |