# Processortyp M fuer Compiler, N fuer avrdude:
M=atmega1284p
N=m1284p

# Compileraufrufe:
C=avr-gcc -mmcu=$M -Wall -Os -c
A=avr-as
L=avr-gcc -mmcu=$M -Wall -Os
L3=avr-gcc -mmcu=$(M3) -Wall -Os

# fuer avrdude-Aufruf unter Linux:
TTY=/dev/ttyUSB0
# fuer avrdude-Aufruf unter MacOSX:
#TTY=/dev/tty.serial-0001

# verwendeter Programmer:
#P=avr910  #fuer mySmartUSB MK2
P=stk500v2 #fuer mySmartUSB light

all: prop2.hex

prop2.hex: prop2.cc
	$L prop2.cc -o prop2.elf
	avr-objcopy -O ihex -R .eeprom prop2.elf prop2.hex
	avr-objdump -h -S prop2.elf > prop2.lss

check:
	avrdude -p $N -c $P -P $(TTY) -v
check2:
	avrdude -p $N -F -c $P -P $(TTY) -v

checkfuses:
	avrdude -p $N -c $P -P $(TTY) -U hfuse:r:-:h -U lfuse:r:-:h

# Fuses fuer Quarz, fuer ATmega8, ATmega32, ATmega328P, ATmega328PB, ATmega1284P:
fusesetzen: 
	avrdude -p $N -c $P -P $(TTY) -U lfuse:w:0xFF:m
	avrdude -p $N -c $P -P $(TTY) -U hfuse:w:0xD1:m
#	avrdude -p $N -c $P -P $(TTY) -U hfuse:w:0xD9:m

install: prop2.hex
	avrdude -p $N -c $P -P $(TTY) -U flash:w:prop2.hex:i

install3: irsender.hex
	avrdude -p $(N3) -c $P -P $(TTY) -U flash:w:irsender.hex:i

clean:
	rm -f *~ *.o *.elf
clean_all:
	rm -f *~ *.o *.elf *.lss *.hex
