Subversion Repositories FlightCtrl

Rev

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

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