Subversion Repositories FlightCtrl

Rev

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