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