Subversion Repositories FlightCtrl

Rev

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

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