Subversion Repositories FlightCtrl

Rev

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