Subversion Repositories FlightCtrl

Rev

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

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