Skip to content

Commit 15a08e6

Browse files
updated Firmata to version 2.3.6
1 parent b84f276 commit 15a08e6

File tree

11 files changed

+1671
-8
lines changed

11 files changed

+1671
-8
lines changed
Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
# Arduino makefile
2+
#
3+
# This makefile allows you to build sketches from the command line
4+
# without the Arduino environment (or Java).
5+
#
6+
# The Arduino environment does preliminary processing on a sketch before
7+
# compiling it. If you're using this makefile instead, you'll need to do
8+
# a few things differently:
9+
#
10+
# - Give your program's file a .cpp extension (e.g. foo.cpp).
11+
#
12+
# - Put this line at top of your code: #include <WProgram.h>
13+
#
14+
# - Write prototypes for all your functions (or define them before you
15+
# call them). A prototype declares the types of parameters a
16+
# function will take and what type of value it will return. This
17+
# means that you can have a call to a function before the definition
18+
# of the function. A function prototype looks like the first line of
19+
# the function, with a semi-colon at the end. For example:
20+
# int digitalRead(int pin);
21+
#
22+
# Instructions for using the makefile:
23+
#
24+
# 1. Copy this file into the folder with your sketch.
25+
#
26+
# 2. Below, modify the line containing "TARGET" to refer to the name of
27+
# of your program's file without an extension (e.g. TARGET = foo).
28+
#
29+
# 3. Modify the line containg "ARDUINO" to point the directory that
30+
# contains the Arduino core (for normal Arduino installations, this
31+
# is the hardware/cores/arduino sub-directory).
32+
#
33+
# 4. Modify the line containing "PORT" to refer to the filename
34+
# representing the USB or serial connection to your Arduino board
35+
# (e.g. PORT = /dev/tty.USB0). If the exact name of this file
36+
# changes, you can use * as a wildcard (e.g. PORT = /dev/tty.USB*).
37+
#
38+
# 5. At the command line, change to the directory containing your
39+
# program's file and the makefile.
40+
#
41+
# 6. Type "make" and press enter to compile/verify your program.
42+
#
43+
# 7. Type "make upload", reset your Arduino board, and press enter to
44+
# upload your program to the Arduino board.
45+
#
46+
# $Id: Makefile,v 1.7 2007/04/13 05:28:23 eighthave Exp $
47+
48+
PORT = /dev/tty.usbserial-*
49+
TARGET := $(shell pwd | sed 's|.*/\(.*\)|\1|')
50+
ARDUINO = /Applications/arduino
51+
ARDUINO_SRC = $(ARDUINO)/hardware/cores/arduino
52+
ARDUINO_LIB_SRC = $(ARDUINO)/hardware/libraries
53+
INCLUDE = -I$(ARDUINO_SRC) -I$(ARDUINO)/hardware/tools/avr/avr/include \
54+
-I$(ARDUINO_LIB_SRC)/EEPROM \
55+
-I$(ARDUINO_LIB_SRC)/Firmata \
56+
-I$(ARDUINO_LIB_SRC)/Servo \
57+
-I$(ARDUINO_LIB_SRC)
58+
SRC = $(wildcard $(ARDUINO_SRC)/*.c)
59+
CXXSRC = applet/$(TARGET).cpp $(ARDUINO_SRC)/HardwareSerial.cpp \
60+
$(ARDUINO_LIB_SRC)/EEPROM/EEPROM.cpp \
61+
$(ARDUINO_LIB_SRC)/Firmata/Firmata.cpp \
62+
$(ARDUINO_LIB_SRC)/Servo/Servo.cpp \
63+
$(ARDUINO_SRC)/WMath.cpp
64+
HEADERS = $(wildcard $(ARDUINO_SRC)/*.h) $(wildcard $(ARDUINO_LIB_SRC)/*/*.h)
65+
66+
MCU = atmega168
67+
#MCU = atmega8
68+
F_CPU = 16000000
69+
FORMAT = ihex
70+
UPLOAD_RATE = 19200
71+
72+
# Name of this Makefile (used for "make depend").
73+
MAKEFILE = Makefile
74+
75+
# Debugging format.
76+
# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
77+
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
78+
DEBUG = stabs
79+
80+
OPT = s
81+
82+
# Place -D or -U options here
83+
CDEFS = -DF_CPU=$(F_CPU)
84+
CXXDEFS = -DF_CPU=$(F_CPU)
85+
86+
# Compiler flag to set the C Standard level.
87+
# c89 - "ANSI" C
88+
# gnu89 - c89 plus GCC extensions
89+
# c99 - ISO C99 standard (not yet fully implemented)
90+
# gnu99 - c99 plus GCC extensions
91+
CSTANDARD = -std=gnu99
92+
CDEBUG = -g$(DEBUG)
93+
CWARN = -Wall -Wstrict-prototypes
94+
CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
95+
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
96+
97+
CFLAGS = $(CDEBUG) $(CDEFS) $(INCLUDE) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA)
98+
CXXFLAGS = $(CDEFS) $(INCLUDE) -O$(OPT)
99+
#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
100+
LDFLAGS =
101+
102+
103+
# Programming support using avrdude. Settings and variables.
104+
AVRDUDE_PROGRAMMER = stk500
105+
AVRDUDE_PORT = $(PORT)
106+
AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex
107+
AVRDUDE_FLAGS = -F -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
108+
-b $(UPLOAD_RATE) -q -V
109+
110+
# Program settings
111+
CC = avr-gcc
112+
CXX = avr-g++
113+
OBJCOPY = avr-objcopy
114+
OBJDUMP = avr-objdump
115+
SIZE = avr-size
116+
NM = avr-nm
117+
AVRDUDE = avrdude
118+
REMOVE = rm -f
119+
MV = mv -f
120+
121+
# Define all object files.
122+
OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
123+
124+
# Define all listing files.
125+
LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
126+
127+
# Combine all necessary flags and optional flags.
128+
# Add target processor to flags.
129+
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
130+
ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS)
131+
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
132+
133+
134+
# Default target.
135+
all: build
136+
137+
build: applet/$(TARGET).hex
138+
139+
eep: applet/$(TARGET).eep
140+
lss: applet/$(TARGET).lss
141+
sym: applet/$(TARGET).sym
142+
143+
144+
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
145+
COFFCONVERT=$(OBJCOPY) --debugging \
146+
--change-section-address .data-0x800000 \
147+
--change-section-address .bss-0x800000 \
148+
--change-section-address .noinit-0x800000 \
149+
--change-section-address .eeprom-0x810000
150+
151+
152+
coff: applet/$(TARGET).elf
153+
$(COFFCONVERT) -O coff-avr applet/$(TARGET).elf applet/$(TARGET).cof
154+
155+
156+
extcoff: applet/$(TARGET).elf
157+
$(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf applet/$(TARGET).cof
158+
159+
160+
.SUFFIXES: .elf .hex .eep .lss .sym .pde
161+
162+
.elf.hex:
163+
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
164+
165+
.elf.eep:
166+
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
167+
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
168+
169+
# Create extended listing file from ELF output file.
170+
.elf.lss:
171+
$(OBJDUMP) -h -S $< > $@
172+
173+
# Create a symbol table from ELF output file.
174+
.elf.sym:
175+
$(NM) -n $< > $@
176+
177+
178+
# Compile: create object files from C++ source files.
179+
.cpp.o: $(HEADERS)
180+
$(CXX) -c $(ALL_CXXFLAGS) $< -o $@
181+
182+
# Compile: create object files from C source files.
183+
.c.o: $(HEADERS)
184+
$(CC) -c $(ALL_CFLAGS) $< -o $@
185+
186+
187+
# Compile: create assembler files from C source files.
188+
.c.s:
189+
$(CC) -S $(ALL_CFLAGS) $< -o $@
190+
191+
192+
# Assemble: create object files from assembler source files.
193+
.S.o:
194+
$(CC) -c $(ALL_ASFLAGS) $< -o $@
195+
196+
197+
198+
applet/$(TARGET).cpp: $(TARGET).pde
199+
test -d applet || mkdir applet
200+
echo '#include "WProgram.h"' > applet/$(TARGET).cpp
201+
echo '#include "avr/interrupt.h"' >> applet/$(TARGET).cpp
202+
sed -n 's|^\(void .*)\).*|\1;|p' $(TARGET).pde | grep -v 'setup()' | \
203+
grep -v 'loop()' >> applet/$(TARGET).cpp
204+
cat $(TARGET).pde >> applet/$(TARGET).cpp
205+
cat $(ARDUINO_SRC)/main.cxx >> applet/$(TARGET).cpp
206+
207+
# Link: create ELF output file from object files.
208+
applet/$(TARGET).elf: applet/$(TARGET).cpp $(OBJ)
209+
$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
210+
211+
pd_close_serial:
212+
echo 'close;' | /Applications/Pd-extended.app/Contents/Resources/bin/pdsend 34567 || true
213+
214+
# Program the device.
215+
upload: applet/$(TARGET).hex
216+
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
217+
218+
219+
pd_test: build pd_close_serial upload
220+
221+
# Target: clean project.
222+
clean:
223+
$(REMOVE) -- applet/$(TARGET).hex applet/$(TARGET).eep \
224+
applet/$(TARGET).cof applet/$(TARGET).elf $(TARGET).map \
225+
applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp \
226+
$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
227+
rmdir -- applet
228+
229+
depend:
230+
if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
231+
then \
232+
sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
233+
$(MAKEFILE).$$$$ && \
234+
$(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
235+
fi
236+
echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
237+
>> $(MAKEFILE); \
238+
$(CC) -M -mmcu=$(MCU) $(CDEFS) $(INCLUDE) $(SRC) $(ASRC) >> $(MAKEFILE)
239+
240+
.PHONY: all build eep lss sym coff extcoff clean depend pd_close_serial pd_test
241+
242+
# for emacs
243+
etags:
244+
make etags_`uname -s`
245+
etags *.pde \
246+
$(ARDUINO_SRC)/*.[ch] \
247+
$(ARDUINO_SRC)/*.cpp \
248+
$(ARDUINO_LIB_SRC)/*/*.[ch] \
249+
$(ARDUINO_LIB_SRC)/*/*.cpp \
250+
$(ARDUINO)/hardware/tools/avr/avr/include/avr/*.[ch] \
251+
$(ARDUINO)/hardware/tools/avr/avr/include/*.[ch]
252+
253+
etags_Darwin:
254+
# etags -a
255+
256+
etags_Linux:
257+
# etags -a /usr/include/*.h linux/input.h /usr/include/sys/*.h
258+
259+
etags_MINGW:
260+
# etags -a /usr/include/*.h /usr/include/sys/*.h
261+
262+
263+

0 commit comments

Comments
 (0)