Subversion Repositories FlightCtrl

Rev

Rev 1186 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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