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