Subversion Repositories FlightCtrl

Rev

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

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