Subversion Repositories FlightCtrl

Rev

Rev 1869 | Rev 1887 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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