#M=attiny13a
M=attiny13
#M=attiny2313

#C=avr-gcc -mmcu=$M -Wall -O1 -c  #nur minimale Optimierung
#C=avr-gcc -mmcu=$M -Wall -O3 -c  #etwas mehr optimieren
#C=avr-gcc -mmcu=$M -Wall -Os -c  #moeglichst kurzer Code
C=avr-gcc -mmcu=$M -Wall -Os -c
A=avr-as
L=avr-gcc -mmcu=$M -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

# Controller:
#K=t2313  #fuer Tiny2313 oder Programmer der den tiny13a nicht kennt
K=t13     #fyer den Tiny13a

all: bewaesserung.hex

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

setfuse4: #fuer 4.8MHz auf Tiny13a
	avrdude -p t13 -c $P -P $(TTY) -U lfuse:w:0x69:m
#	avrdude -p t13 -c $P -P $(TTY) -U hfuse:w:0xFF:m
setfuse: #fuer 8 bis 9.6MHz auf Tiny13a, (mit CLKDIV8 also 1 bis 1.2MHz = default)
	avrdude -p t13 -c $P -P $(TTY) -U lfuse:w:0x6A:m
#	avrdude -p t13 -c $P -P $(TTY) -U hfuse:w:0xFF:m

check:
	avrdude -p $K -c $P -P $(TTY) -v

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

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