Subversion Repositories FlightCtrl

Rev

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

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