Subversion Repositories FlightCtrl

Rev

Details | Last modification | View Log | RSS feed

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