Subversion Repositories FlightCtrl

Rev

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