Subversion Repositories FlightCtrl

Rev

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

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