Subversion Repositories FlightCtrl

Rev

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

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