OBJ            = borg_hw.o main.o util.o pixel.o programm.o borg_can.o can.o \
				 spi.o scrolltext3.o font_arial8.o joystick.o snake.o \
				 eeprom_reserve.o persistentCounter.o prng.o matrix.o \
				 invader_draw.o invader_init.o invader_proc.o invaders2.o \
				 tetris/tetris.o menu.o gameoflife.o memxor.o noekeon_asm.o \
				 mcuf.o uart.o

CANADDR        = 0x43

SERIAL = /dev/ttyUSB0

include ../../make/avr.mk

.PHONY: tetris/tetris.o
tetris/tetris.o:
	$(MAKE) "MCU_CC=$(MCU_CC)" "MCU_LD=$(MCU_LD)" "LDFLAGS=$(LDFLAGS)" \
		"CFLAGS=$(CFLAGS) -DNDEBUG -pedantic -std=c99" --directory=tetris

LAUNCH_BOOTLOADER = launch-bootloader

sflash: $(OUT).hex
	$(LAUNCH_BOOTLOADER) $(SERIAL) 115200
	avrdude -p m32 -b 115200 -u -c avr109 -P $(SERIAL) -U f:w:$(OUT).hex -F
	echo X > $(SERIAL)

urflash: image_with_bootloader.hex
	avrdude -p m32 -c bsd -P /dev/parport0 -U hfuse:w:0xdc:m
	avrdude -p m32 -c bsd -P /dev/parport0 -U lfuse:w:0xef:m
	avrdude -p m32 -c bsd -P /dev/parport0 -U f:w:image_with_bootloader.hex
	avrdude -p m32 -c bsd -P /dev/parport0 -U e:w:image_eeprom.hex
	avrdude -p m32 -c bsd -P /dev/parport0 -U lock:w:0x2f:m