Subversion Repositories FlightCtrl

Rev

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