Subversion Repositories FlightCtrl

Rev

Rev 903 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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