Skript file: /~heha/basteln/PC/FunkUsb/FunkUsb.zip/FunkUsb/joy/Makefile

# FunkUsb, HID:Joystick version
#240611	Makefile modernized, no intermediate object files, binary .flash file
P = FunkUsb
D = attiny25
F = 16500000

AVRDUDE = avrdude -c pony-stk200 -P lpt1 -p $D
USBDRV = ../../usbdrv
WINAVR = c:/Programme/WinAVR
PATH := $(WINAVR)/gcc1010/bin;$(PATH)

CC = avr-gcc -Wall -Os -fno-move-loop-invariants -I. -I$(USBDRV) -mmcu=$D -DF_CPU=$F

SRC = $(USBDRV)/usbdrvasm.S $P.c

# symbolic targets:
all: $P.flash $P.lst

flash: $P.flash
	$(AVRDUDE) -U $@:w:$<:r


# Fuse high byte:
HFUSE=0b11010101
#	│││││└┴┴BODLEVEL 2..0 (brownout trigger level → 2.7V)
#	││││└───EESAVE (preserve EEPROM on Chip Erase → preserve)
#	│││└────WDTON (watchdog timer always on → disable)
#	││└─────SPIEN (enable serial programming → enabled)
#	│└──────DWEN (debug wire enable → disabled)
#	└───────RSTDISBL (disable external reset → enabled)

# Fuse low byte:
LFUSE=0b11100001
#	││└┤└┴┴┴CKSEL 3..0 (clock selection → HF PLL)
#	││ └────SUT 1..0 (BOD enabled, fast rising power)
#	│└──────CKOUT (clock output on CKOUT pin → disabled)
#	└───────CKDIV8 (divide clock by 8 → don't divide)

program:
	$(AVRDUDE) -U hfuse:w:$(HFUSE):m -U lfuse:w:$(LFUSE):m -U flash:w:$P.flash:r

readcal:
	$(AVRDUDE) -U calibration:r:con:i

clean:
	rm -f $P.flash $P.eeprom $P.lst $P.elf

# file targets:
$P.elf: $(SRC) *.h Makefile
	$(CC) -o $@ $(SRC)
	$(WINAVR)/bin/avr-size --mcu=$D -C $@

%.flash: %.elf
	avr-objcopy -j .text -j .data -O binary $< $@

%.lst: %.elf
	avr-objdump -d $< >$@
	avr-strip $<
Detected encoding: UTF-80