Subversion Repositories FlightCtrl

Rev

Rev 1749 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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