Subversion Repositories FlightCtrl

Rev

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

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