# Processortyp M fuer Compiler, N fuer avrdude:
M=atmega8
N=m8
# Compileraufrufe:
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

all: lcdtest.hex softuart.hex

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

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

lcdmodul2.o:  lcdmodul2.h lcdmodul2.cc
	$C lcdmodul2.cc -o lcdmodul2.o

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

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

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

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

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