Subversion Repositories FlightCtrl

Rev

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

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