Subversion Repositories FlightCtrl

Rev

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