Subversion Repositories FlightCtrl

Rev

Rev 868 | Details | Compare with Previous | Last modification | View Log | RSS feed

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