Subversion Repositories FlightCtrl

Rev

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

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