瀏覽代碼

allow Marlin to actually compile with Makefile pulled from Sprinter and a few other modifications

Michael Moon 12 年之前
父節點
當前提交
8d0916af13
共有 5 個檔案被更改,包括 164 行新增266 行删除
  1. 153
    257
      Marlin/Makefile
  2. 2
    2
      Marlin/Marlin.h
  3. 4
    2
      Marlin/Marlin.pde
  4. 0
    0
      Marlin/cardreader.cpp
  5. 5
    5
      Marlin/temperature.cpp

+ 153
- 257
Marlin/Makefile 查看文件

@@ -1,76 +1,65 @@
1
+# Sprinter Arduino Project Makefile
2
+# 
3
+# Makefile Based on:
4
+# Arduino 0011 Makefile
5
+# Arduino adaptation by mellis, eighthave, oli.keller
6
+#
7
+# This has been tested with Arduino 0022.
8
+# 
9
+# This makefile allows you to build sketches from the command line
10
+# without the Arduino environment (or Java).
11
+#
12
+# Detailed instructions for using the makefile:
13
+#
14
+#  1. Modify the line containg "INSTALL_DIR" to point to the directory that
15
+#     contains the Arduino installation (for example, under Mac OS X, this
16
+#     might be /Applications/arduino-0012).
17
+#
18
+#  2. Modify the line containing "PORT" to refer to the filename
19
+#     representing the USB or serial connection to your Arduino board
20
+#     (e.g. PORT = /dev/tty.USB0).  If the exact name of this file
21
+#     changes, you can use * as a wildcard (e.g. PORT = /dev/tty.usb*).
22
+#
23
+#  3. Set the line containing "MCU" to match your board's processor. 
24
+#     Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
25
+#     or Diecimila have the atmega168.  If you're using a LilyPad Arduino,
26
+#     change F_CPU to 8000000.
27
+#
28
+#  4. Type "make" and press enter to compile/verify your program.
29
+#
30
+#  5. Type "make upload", reset your Arduino board, and press enter to
31
+#     upload your program to the Arduino board.
32
+#
33
+# $Id$
34
+
1 35
 TARGET = $(notdir $(CURDIR))
2
-# CHANGE BELOW:
3
-#~ INSTALL_DIR = /Applications/Arduino.app/Contents/Resources/Java
4
-INSTALL_DIR = /home/bkubicek/software/arduino-0023
5
-#~ PORT = /dev/cu.usbserial*
6
-PORT = /dev/ttyACM0
7
-
8
-# Get these values from:
9
-#     $(INSTALL_DIR)/hardware/boards.txt
10
-#     (arduino-0022/hardware/arduino/boards.txt)
11
-# The values below are for the "Arduino Duemilanove or Nano w/ ATmega328"
12
-# now for "Arduino Mega 2560"
13
-UPLOAD_SPEED = 115200
14
-UPLOAD_PROTOCOL = stk500v2
15
-BUILD_MCU = atmega2560
16
-BUILD_F_CPU = 16000000L
17
-TERM=bash
18
-
19
-# getting undefined reference to `__cxa_pure_virtual'
20
-#~ [http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1254180518 Arduino Forum - Makefile]
21
-#~ http://www.arduino.cc/playground/OpenBSD/CLI
22
-#~ [http://arduino.cc/forum/index.php?topic=52041.0 A "simple" makefile for Arduino]
23
-#~ [http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1275488191 Arduino Forum - Configuring avr-gcc options in arduino IDE]
24
-# found in /usr/lib/gcc/avr/4.3.5/cc1plus; fixed with -Wl,--gc-section
36
+INSTALL_DIR = ../../arduino-0022/
37
+UPLOAD_RATE = 115200
38
+AVRDUDE_PROGRAMMER = arduino
39
+# PORT = /dev/arduino_A900G2I3
40
+PORT = /dev/arduino
41
+MCU = atmega1280
42
+#For "old" Arduino Mega
43
+#MCU = atmega1280
44
+#For Sanguinololu
45
+#MCU = atmega644p 
46
+F_CPU = 16000000
47
+
25 48
 
26 49
 ############################################################################
27 50
 # Below here nothing should be changed...
28 51
 
29
-LINKORDER=\
30
-applet/Marlin.cpp.o \
31
-applet/EEPROM.o  \
32
-applet/main.o \
33
-applet/MarlinSerial.o \
34
-applet/motion_control.o\
35
-applet/pins_arduino.o\
36
-applet/planner.o\
37
-applet/Print.o\
38
-applet/Sd2Card.o\
39
-applet/SdBaseFile.o\
40
-applet/SdFatUtil.o\
41
-applet/SdFile.o\
42
-applet/SdVolume.o\
43
-applet/stepper.o\
44
-applet/temperature.o\
45
-applet/WInterrupts.o\
46
-applet/wiring_analog.o\
47
-applet/wiring_digital.o\
48
-applet/wiring.o\
49
-applet/wiring_pulse.o\
50
-applet/wiring_shift.o\
51
-applet/WMath.o
52
-
53
-PDES=Marlin.pde  ultralcd.pde  watchdog.pde cardreader.pde  
54 52
 ARDUINO = $(INSTALL_DIR)/hardware/arduino/cores/arduino
55
-#
56
-#~ AVR_TOOLS_PATH = $(INSTALL_DIR)/hardware/tools/avr/bin
57
-# in Ubuntu, avr-gcc is installed separate;
58
-# only avrdude comes with the IDE
59
-AVR_TOOLS_PATH = /usr/bin
60
-AVR_DUDE_PATH = $(INSTALL_DIR)/hardware/tools
61
-#
62
-SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
63
-    $(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
64
-    $(ARDUINO)/wiring_pulse.c \
65
-    $(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
66
-# added applet/$(TARGET).cpp as in IDE 0022
67
-CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WMath.cpp \
68
-    $(ARDUINO)/Print.cpp \
69
-    $(ARDUINO)/main.cpp
70
-#    applet/$(TARGET).cpp # no need, having a rule now for applet/$(TARGET).cpp.o
71
-# added main.cpp, as in 0022
53
+AVR_TOOLS_PATH = 
54
+SRC =  $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
55
+$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
56
+$(ARDUINO)/wiring_pulse.c \
57
+$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
58
+CXXSRC = $(ARDUINO)/WMath.cpp $(ARDUINO)/WString.cpp\
59
+$(ARDUINO)/Print.cpp Marlin.cpp MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp stepper.cpp temperature.cpp cardreader.cpp
72 60
 FORMAT = ihex
73 61
 
62
+
74 63
 # Name of this Makefile (used for "make depend").
75 64
 MAKEFILE = Makefile
76 65
 
@@ -79,192 +68,128 @@ MAKEFILE = Makefile
79 68
 # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
80 69
 DEBUG = stabs
81 70
 
82
-OPT = 2
71
+OPT = s
83 72
 
84 73
 # Place -D or -U options here
85
-#~ CDEFS = -DBUILD_F_CPU=$(BUILD_F_CPU)
86
-#~ CXXDEFS = -DBUILD_F_CPU=$(BUILD_F_CPU)
87
-# now called DF_CPU
88
-CDEFS = -DF_CPU=$(BUILD_F_CPU) -DARDUINO=23
89
-CXXDEFS = -DF_CPU=$(BUILD_F_CPU) -DARDUINO=23
74
+CDEFS = -DF_CPU=$(F_CPU)
75
+CXXDEFS = -DF_CPU=$(F_CPU)
90 76
 
91 77
 # Place -I options here
92
-CINCS = -I$(ARDUINO) -I$(INSTALL_DIR)/libraries/LiquidCrystal/ -I$(INSTALL_DIR)/libraries/EEPROM/
78
+CINCS = -I$(ARDUINO)
93 79
 CXXINCS = -I$(ARDUINO)
94 80
 
95 81
 # Compiler flag to set the C Standard level.
96
-# c89 - "ANSI" C
82
+# c89   - "ANSI" C
97 83
 # gnu89 - c89 plus GCC extensions
98
-# c99 - ISO C99 standard (not yet fully implemented)
84
+# c99   - ISO C99 standard (not yet fully implemented)
99 85
 # gnu99 - c99 plus GCC extensions
100
-CSTANDARD = -std=gnu99
86
+#CSTANDARD = -std=gnu99
101 87
 CDEBUG = -g$(DEBUG)
102
-# note that typically, IDE 0022 uses -w to suppress warnings (both in cpp and c)!
103
-CWARN = -Wall
104
-#~ CWARN = -w
105
-#  "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++:
106
-CCWARN = -Wstrict-prototypes
107
-CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
88
+CWARN = -Wall -Wstrict-prototypes
89
+CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -w -ffunction-sections -fdata-sections -DARDUINO=22
108 90
 #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
109 91
 
110
-# to eliminate pins_ardiuno warnings:
111
-# http://arduino.cc/pipermail/developers_arduino.cc/2010-December/004005.html
112
-
113
-# [http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1254180518 Arduino Forum - Makefile]
114
-#~ For building the objects files "-ffunction-sections -fdata-sections" was missing
115
-#~ and the final avr-gcc call needs "-Wl,--gc-section".
116
-CXSECTF = -fno-exceptions -ffunction-sections -fdata-sections
117
-CFINALF = -Wl,--gc-section
118
-
119
-CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CCWARN) $(CSTANDARD) $(CEXTRA)
120
-# added CWARN also to .cpp
121
-CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CXSECTF)
122
-#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
92
+CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING)
93
+CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING)
94
+#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs 
123 95
 LDFLAGS = -lm
124 96
 
97
+
125 98
 # Programming support using avrdude. Settings and variables.
126 99
 AVRDUDE_PORT = $(PORT)
127
-AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex
128
-AVRDUDE_FLAGS = -V -F \
129
-    -p $(BUILD_MCU) -P $(AVRDUDE_PORT) -c $(UPLOAD_PROTOCOL) \
130
-    -b $(UPLOAD_SPEED) -C $(INSTALL_DIR)/hardware/tools/avrdude.conf
131
-#    -b $(UPLOAD_SPEED) -C $(INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf
100
+AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex:i
101
+AVRDUDE_FLAGS = -D -C $(INSTALL_DIR)/hardware/tools/avrdude.conf \
102
+-p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
103
+-b $(UPLOAD_RATE)
132 104
 
133 105
 # Program settings
134
-CC = $(AVR_TOOLS_PATH)/avr-gcc
135
-CXX = $(AVR_TOOLS_PATH)/avr-g++
136
-OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy
137
-OBJDUMP = $(AVR_TOOLS_PATH)/avr-objdump
138
-AR = $(AVR_TOOLS_PATH)/avr-ar
139
-SIZE = $(AVR_TOOLS_PATH)/avr-size
140
-NM = $(AVR_TOOLS_PATH)/avr-nm
141
-#~ AVRDUDE = $(AVR_TOOLS_PATH)/avrdude
142
-AVRDUDE = $(AVR_DUDE_PATH)/avrdude
106
+CC = $(AVR_TOOLS_PATH)avr-gcc
107
+CXX = $(AVR_TOOLS_PATH)avr-g++
108
+OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
109
+OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
110
+AR  = $(AVR_TOOLS_PATH)avr-ar
111
+SIZE = $(AVR_TOOLS_PATH)avr-size
112
+NM = $(AVR_TOOLS_PATH)avr-nm
113
+AVRDUDE = avrdude
143 114
 REMOVE = rm -f
144 115
 MV = mv -f
145 116
 
146 117
 # Define all object files.
147
-# NOTE: obj files will be created in respective src directories (libraries or $(INSTALL_DIR));
148
-#  make clean deletes them fine
149
-# note that srcs are in libraries or other directories;
150
-# $(CXXSRC:.cpp=.o) will cause obj files to be in same loc as src files
151
-#~ OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
152
-# to change the output directory for object files;
153
-# must change the obj list here!
154
-# and then, match to corresponding rule somehow?
155
-# or leave this - and parse in rule (auth automatic variable $(@F))?
156
-# "Suffix Replacement"
157
-CXXSRC+=MarlinSerial.cpp    SdBaseFile.cpp  stepper.cpp motion_control.cpp SdFatUtil.cpp temperature.cpp planner.cpp SdFile.cpp Sd2Card.cpp SdVolume.cpp
158
-OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
159
-
160
-# added - OBJ list, transformed into applet/
161
-OBJT = $(addprefix applet/,$(notdir $(OBJ)))
162
-ALLSRC = $(SRC) $(CXXSRC) $(ASRC)
118
+OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o) 
163 119
 
164 120
 # Define all listing files.
165 121
 LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
166 122
 
167 123
 # Combine all necessary flags and optional flags.
168 124
 # Add target processor to flags.
169
-ALL_CFLAGS = -mmcu=$(BUILD_MCU) -I. $(CFLAGS)
170
-ALL_CXXFLAGS = -mmcu=$(BUILD_MCU) -I. $(CXXFLAGS)
171
-ALL_ASFLAGS = -mmcu=$(BUILD_MCU) -I. -x assembler-with-cpp $(ASFLAGS)
172
-
173
-# depended libraries of .pde need to be added from
174
-# $(INSTALL_DIR)/libraries (TODO: and/or ~/sketchbook/libraries)
175
-# grep for 'include', test if exists, add...
176
-# note: prefix "a real tab character" http://www.delorie.com/djgpp/doc/ug/larger/makefiles.html
177
-# $$ to escape $ for shell;
178
-# note: must NOT put comments # inside bash execution;
179
-# those would get removed by make; making shell see "EOF in backquote substitution"
180
-#		 echo $$ix ; \
181
-# 'shell' twice - for each subprocess! Backtick doesn't get expanded?
182
-GREPRES:=$(shell for ix in $(shell grep include $(TARGET).pde | sed 's/.*[<"]\(.*\).h[>"].*/\1/'); do \
183
-		if [ -d $(INSTALL_DIR)/libraries/$$ix ] ; then \
184
-			LINCS="$$LINCS -I$(INSTALL_DIR)/libraries/$$ix" ;\
185
-		fi; \
186
-	done; \
187
-	echo $$LINCS)
188
-# append includes:
189
-CINCS += $(GREPRES)
190
-CXXINCS += $(GREPRES)
191
-# append library source .cpp files too (CXXSRC)
192
-GREPRESB:=$(shell for ix in $(shell grep include $(TARGET).pde | sed 's/.*[<"]\(.*\).h[>"].*/\1/'); do \
193
-		if [ -d $(INSTALL_DIR)/libraries/$$ix ] ; then \
194
-			CPPSRCS="$$CPPSRCS $(INSTALL_DIR)/libraries/$$ix/*.cpp" ;\
195
-		fi; \
196
-	done; \
197
-	echo $$CPPSRCS)
198
-CXXSRC += $(GREPRESB)
199
-# added - only CXX obj from libraries:
200
-CXXLIBOBJ = $(GREPRESB:.cpp=.o)
125
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
126
+ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS)
127
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
128
+
201 129
 
202 130
 # Default target.
203 131
 all: applet_files build sizeafter
204 132
 
205
-build: elf hex
133
+build: elf hex 
206 134
 
207 135
 applet_files: $(TARGET).pde
208
-    # Here is the "preprocessing".
209
-    # It creates a .cpp file based with the same name as the .pde file.
210
-    # On top of the new .cpp file comes the WProgram.h header.
211
-    # At the end there is a generic main() function attached.
212
-    # Then the .cpp file will be compiled. Errors during compile will
213
-    # refer to this new, automatically generated, file.
214
-    # Not the original .pde file you actually edit...
136
+	# Here is the "preprocessing".
137
+	# It creates a .cpp file based with the same name as the .pde file.
138
+	# On top of the new .cpp file comes the WProgram.h header.
139
+	# At the end there is a generic main() function attached.
140
+	# Then the .cpp file will be compiled. Errors during compile will
141
+	# refer to this new, automatically generated, file. 
142
+	# Not the original .pde file you actually edit...
215 143
 	test -d applet || mkdir applet
216
-    # @ supresses printout of the cmdline itself; so only the out of echo is printed
217
-	@echo ALL OBJT: $(OBJT)
218
-	@echo ALL CXXLIBOBJ: $(CXXLIBOBJ)
219
-#	echo '#include "WProgram.h"' > applet/$(TARGET).cpp
220
-	@echo "#include \"WProgram.h\"\nvoid setup();\nvoid loop();\n" > applet/$(TARGET).cpp
221
-	##cat $(TARGET).pde >> applet/$(TARGET).cpp
222
-	cat ${PDES}>> applet/$(TARGET).cpp
223
-	cp *.cpp applet/
224
-    # no more need to cat main.cpp (v0022) - now it is compiled in
225
-#	cat $(ARDUINO)/main.cpp >> applet/$(TARGET).cpp
226
-
144
+	echo '#include "WProgram.h"' > applet/$(TARGET).cpp
145
+	cat $(TARGET).pde >> applet/$(TARGET).cpp
146
+	cat $(ARDUINO)/main.cpp >> applet/$(TARGET).cpp
227 147
 
228 148
 elf: applet/$(TARGET).elf
229 149
 hex: applet/$(TARGET).hex
230 150
 eep: applet/$(TARGET).eep
231
-lss: applet/$(TARGET).lss
151
+lss: applet/$(TARGET).lss 
232 152
 sym: applet/$(TARGET).sym
233 153
 
234
-# Program the device.
154
+# Program the device.  
235 155
 upload: applet/$(TARGET).hex
236 156
 	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
237 157
 
238
-# Display size of file.
158
+
159
+	# Display size of file.
239 160
 HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex
240
-ELFSIZE = $(SIZE) applet/$(TARGET).elf
161
+ELFSIZE = $(SIZE)  applet/$(TARGET).elf
241 162
 sizebefore:
242 163
 	@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
243 164
 
244 165
 sizeafter:
245 166
 	@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(HEXSIZE); echo; fi
246 167
 
168
+
247 169
 # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
248 170
 COFFCONVERT=$(OBJCOPY) --debugging \
249
-    --change-section-address .data-0x800000 \
250
-    --change-section-address .bss-0x800000 \
251
-    --change-section-address .noinit-0x800000 \
252
-    --change-section-address .eeprom-0x810000
171
+--change-section-address .data-0x800000 \
172
+--change-section-address .bss-0x800000 \
173
+--change-section-address .noinit-0x800000 \
174
+--change-section-address .eeprom-0x810000 
175
+
253 176
 
254 177
 coff: applet/$(TARGET).elf
255 178
 	$(COFFCONVERT) -O coff-avr applet/$(TARGET).elf $(TARGET).cof
256 179
 
180
+
257 181
 extcoff: $(TARGET).elf
258 182
 	$(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf $(TARGET).cof
259 183
 
184
+
260 185
 .SUFFIXES: .elf .hex .eep .lss .sym
261 186
 
262 187
 .elf.hex:
263 188
 	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
264 189
 
265 190
 .elf.eep:
266
-    -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
267
-    --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
191
+	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
192
+	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
268 193
 
269 194
 # Create extended listing file from ELF output file.
270 195
 .elf.lss:
@@ -274,79 +199,50 @@ extcoff: $(TARGET).elf
274 199
 .elf.sym:
275 200
 	$(NM) -n $< > $@
276 201
 
277
-# Link: create ELF output file from library.
278
-# NOTE: applet/$(TARGET).cpp.o MUST BE BEFORE applet/core.a
279
-#  in the dependency list, so its rule runs first!
280
-applet/$(TARGET).elf: $(TARGET).pde applet/$(TARGET).cpp.o applet/core.a
281
-#	$(CC) $(ALL_CFLAGS) -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
282
-# changed as in IDE v0022: link cpp obj files
283
-	@echo $$(tput bold)$$(tput setaf 2) $(CC) $$(tput sgr0) $(ALL_CFLAGS) $(CFINALF) -o $@ applet/$(TARGET).cpp.o $(CXXOBJ) -L. applet/core.a $(LDFLAGS)
284
-	echo ${OBJT}
285
-	#$(CC) $(ALL_CFLAGS) $(CFINALF) -o $@  applet/$(TARGET).cpp.o  -L. applet/core.a $(LDFLAGS)
286
-	$(CC) $(ALL_CFLAGS) $(CFINALF) -o $@ ${LINKORDER}   $(LDFLAGS)
287
-	#@$(CC) $(ALL_CFLAGS) $(CFINALF) -o $@ applet/*.o applet/$(TARGET).cpp.o $(CXXOBJ) -L. applet/core.a $(LDFLAGS)
288
-
289
-# added: cpp.o depends on cpp (and .pde which generates it)
290
-# $< "first item in the dependencies list"; $@ "left side of the :"; $^ "right side of the :"
291
-# http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
292
-applet/$(TARGET).cpp.o: applet/$(TARGET).cpp
293
-	@echo $$(tput bold) $(CXX) $$(tput sgr0) -c $(ALL_CXXFLAGS) $< -o $@
294
-	@$(CXX) -c $(ALL_CXXFLAGS) $< -o $@
295
-
296
-#~ applet/core.a: $(OBJ)
297
-#~	 @for i in $(OBJ); do echo $(AR) rcs applet/core.a $$i; $(AR) rcs applet/core.a $$i; done
298
-
299
-applet/core.a: $(OBJT)
300
-	 @for i in $(OBJT); do echo $(AR) rcs applet/core.a $$i; $(AR) rcs applet/core.a $$i; done
301
-
302
-# iterate through OBJ to find the original location; then build depending on source extension
303
-# TODO: add handling of assembler files
304
-applet/%.o:
305
-	@for iob in $(OBJ); do \
306
-		if [ "`basename $$iob`" = "`basename $@`" ]; then \
307
-			for ios in $(ALLSRC); do \
308
-				if [ "$${iob%%.*}" = "$${ios%%.*}" ]; then \
309
-					case $${ios##*.} in \
310
-						"cpp") \
311
-							echo "$$(tput bold)$$(tput setaf 1) $(CXX) $$(tput sgr0) -c $(ALL_CXXFLAGS) $$ios -o $@"; \
312
-							$(CXX) -c $(ALL_CXXFLAGS) $$ios -o $@;; \
313
-						"c") \
314
-							echo "$$(tput bold)$$(tput setaf 1) $(CC) $$(tput sgr0) -c $(ALL_CFLAGS) $$ios -o $@"; \
315
-							$(CC) -c $(ALL_CFLAGS) $$ios -o $@;; \
316
-					esac; \
317
-				fi; \
318
-			done; \
319
-		fi; \
320
-	done;
321
-
322
-#~ # Compile: create object files from C++ source files.
323
-#~ .cpp.o:
324
-#~	 $(CXX) -c $(ALL_CXXFLAGS) $< -o $@
325
-
326
-#~ # Compile: create object files from C source files.
327
-#~ .c.o:
328
-#~	 $(CC) -c $(ALL_CFLAGS) $< -o $@
329
-
330
-#~ # Compile: create assembler files from C source files.
331
-#~ .c.s:
332
-#~	 $(CC) -S $(ALL_CFLAGS) $< -o $@
333
-
334
-#~ # Assemble: create object files from assembler source files.
335
-#~ .S.o:
336
-#~	 $(CC) -c $(ALL_ASFLAGS) $< -o $@
337
-
338
-#~ # Automatic dependencies
339
-#~ %.d: %.c
340
-#~	 $(CC) -M $(ALL_CFLAGS) $< | sed "s;$(notdir $*).o:;$*.o $*.d:;" > $@
341
-
342
-#~ %.d: %.cpp
343
-#~	 $(CXX) -M $(ALL_CXXFLAGS) $< | sed "s;$(notdir $*).o:;$*.o $*.d:;" > $@
202
+	# Link: create ELF output file from library.
203
+applet/$(TARGET).elf: $(TARGET).pde applet/core.a 
204
+	$(CC) $(ALL_CFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
205
+
206
+applet/core.a: $(OBJ)
207
+	@for i in $(OBJ); do echo $(AR) rcs applet/core.a $$i; $(AR) rcs applet/core.a $$i; done
208
+
209
+
210
+
211
+# Compile: create object files from C++ source files.
212
+.cpp.o:
213
+	$(CXX) -c $(ALL_CXXFLAGS) $< -o $@ 
214
+
215
+# Compile: create object files from C source files.
216
+.c.o:
217
+	$(CC) -c $(ALL_CFLAGS) $< -o $@ 
218
+
219
+
220
+# Compile: create assembler files from C source files.
221
+.c.s:
222
+	$(CC) -S $(ALL_CFLAGS) $< -o $@
223
+
224
+
225
+# Assemble: create object files from assembler source files.
226
+.S.o:
227
+	$(CC) -c $(ALL_ASFLAGS) $< -o $@
228
+
229
+
344 230
 
345 231
 # Target: clean project.
346 232
 clean:
347 233
 	$(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
348
-        applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/core.a \
349
-        $(OBJT) applet/$(TARGET).cpp.o \
350
-        $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
351
-
352
-.PHONY: all build elf hex eep lss sym program coff extcoff clean applet_files sizebefore sizeafter
234
+	applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/core.a \
235
+	$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
236
+
237
+depend:
238
+	if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
239
+	then \
240
+		sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
241
+			$(MAKEFILE).$$$$ && \
242
+		$(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
243
+	fi
244
+	echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
245
+		>> $(MAKEFILE); \
246
+	$(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
247
+
248
+.PHONY:	all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter

+ 2
- 2
Marlin/Marlin.h 查看文件

@@ -14,7 +14,7 @@
14 14
 #include <string.h>
15 15
 #include <inttypes.h>
16 16
 
17
-#include <avr/delay.h>
17
+#include <util/delay.h>
18 18
 #include <avr/pgmspace.h>
19 19
 #include <avr/eeprom.h>
20 20
 #include  <avr/wdt.h>
@@ -55,7 +55,7 @@
55 55
 // //# define MYPGM(s) (__extension__({static prog_char __c[] = (s); &__c[0];})) 
56 56
 // //#define MYPGM(s) ((const prog_char *g PROGMEM=s))
57 57
 // //#define MYPGM(s) PSTR(s)
58
-#define MYPGM(s)  (__extension__({static char __c[] __attribute__((__progmem__)) = (s); &__c[0];}))  //This is the normal behaviour
58
+#define MYPGM(s)  (__extension__({static const char __c[] __attribute__((__progmem__)) = (s); &__c[0];}))  //This is the normal behaviour
59 59
 //#define MYPGM(s)  (__extension__({static prog_char __c[]  = (s); &__c[0];})) //this does not work but hides the warnings
60 60
 
61 61
 

+ 4
- 2
Marlin/Marlin.pde 查看文件

@@ -1301,8 +1301,10 @@ void manage_inactivity(byte debug)
1301 1301
       last_stepperdisabled_time=previous_millis_cmd;
1302 1302
     else
1303 1303
     {
1304
-      if(  (X_ENABLE_ON && (READ(X_ENABLE_PIN)!=0))  ||  (!X_ENABLE_ON && READ(X_ENABLE_PIN)==0)  )
1305
-        enquecommand(DEFAULT_STEPPER_DEACTIVE_COMMAND); 
1304
+      #if X_ENABLE_PIN >= 0
1305
+        if(  (X_ENABLE_ON && (READ(X_ENABLE_PIN)!=0))  ||  (!X_ENABLE_ON && READ(X_ENABLE_PIN)==0)  )
1306
+          enquecommand(DEFAULT_STEPPER_DEACTIVE_COMMAND); 
1307
+      #endif
1306 1308
       last_stepperdisabled_time=millis();
1307 1309
     }
1308 1310
   }

Marlin/cardreader.pde → Marlin/cardreader.cpp 查看文件


+ 5
- 5
Marlin/temperature.cpp 查看文件

@@ -85,9 +85,9 @@ static unsigned long  previous_millis_bed_heater;
85 85
   static unsigned char soft_pwm[EXTRUDERS];
86 86
   
87 87
 #ifdef WATCHPERIOD
88
-  static int watch_raw[EXTRUDERS] = { -1000 }; // the first value used for all
89
-  static int watch_oldtemp[3] = {0,0,0};
90
-  static unsigned long watchmillis = 0;
88
+  int watch_raw[EXTRUDERS] = { -1000 }; // the first value used for all
89
+  int watch_oldtemp[3] = {0,0,0};
90
+  unsigned long watchmillis = 0;
91 91
 #endif //WATCHPERIOD
92 92
 
93 93
 // Init min and max temp with extreme values to prevent false errors during startup
@@ -218,7 +218,7 @@ void manage_heater()
218 218
   
219 219
   #ifdef WATCHPERIOD
220 220
     if(watchmillis && millis() - watchmillis > WATCHPERIOD){
221
-        if(watch_oldtemp[TEMPSENSOR_HOTEND_0] >= degHotend(active_extruder)){
221
+        if(watch_oldtemp[0] >= degHotend(active_extruder)){
222 222
             setTargetHotend(0,active_extruder);
223 223
             LCD_MESSAGEPGM("Heating failed");
224 224
             SERIAL_ECHO_START;
@@ -527,7 +527,7 @@ void setWatch()
527 527
   for (int e = 0; e < EXTRUDERS; e++)
528 528
   {
529 529
     if(isHeatingHotend(e))
530
-    watch_oldtemp[TEMPSENSOR_HOTEND_0] = degHotend(0);
530
+    watch_oldtemp[0] = degHotend(0);
531 531
     {
532 532
       t = max(t,millis());
533 533
       watch_raw[e] = current_raw[e];

Loading…
取消
儲存