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