# # Template for Arduino projects # # Edit variables below then type "make" to build and # "make upload" to upload to your Arduino. # # Before using this, you'll need to install the library and # header file. # # To compile target.pde, create target.c or target.cpp with # contents # # #include # # #include "target.pde" # # int main(void) { # init(); # setup(); # for(;;) # loop(); # return 0; # } # # and add -I. to your CFLAGS and/or CPPFLAGS. # # Tested with Arduino Duemilanove with ATmega328p. May work with # others, but then again, it may not. # # You will need: # - avr-gcc # - avr-binutils # - avr-libc # - avrdude # # Contact: avf [at] eldamar.org.uk # # Your board MCU = atmega328p F_CPU = 16000000 # Settings for programming RATE = 57600 PROG = stk500v1 PORT = /dev/ttyU1 # List of object files and name of final target OBJS = template.o TARGET = template # Put your include and library paths and libraries here CFLAGS = CPPFLAGS= LDFLAGS = ############### CC = avr-gcc CXX = avr-g++ OBJCOPY = avr-objcopy AVRDUDE = sudo avrdude CFLAGS += -mmcu=$(MCU) -DF_CPU=$(F_CPU) -gstabs -Os -Wall -Wstrict-prototypes CPPFLAGS+= -mmcu=$(MCU) -DF_CPU=$(F_CPU) -gstabs -Os -Wall LDFLAGS += -larduino -lm ############### all: $(TARGET) $(TARGET): $(TARGET).hex $(TARGET).hex: $(TARGET).elf $(OBJCOPY) -O ihex -R .eeprom $(TARGET).elf $(TARGET).hex $(TARGET).elf: $(OBJS) $(CC) $(CFLAGS) -o $(TARGET).elf $(OBJS) $(LDFLAGS) clean: rm -f *.o $(TARGET).elf $(TARGET).hex upload: $(TARGET).hex $(AVRDUDE) -V -F -p $(MCU) -P $(PORT) -c $(PROG) -b $(RATE) -U flash:w:$(TARGET).hex