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