Subversion Repositories FlightCtrl

Rev

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

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