Subversion Repositories FlightCtrl

Rev

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

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