Subversion Repositories FlightCtrl

Rev

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

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