-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
54 lines (39 loc) · 1.04 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
CC=avr-gcc
AS=$(CC)
LD=$(CC)
CPU=atmega8
AVRDUDE=avrdude -p m8 -P usb -c avrispmkII
CFLAGS=-Wall -mmcu=$(CPU) -Os -DF_CPU=8000000L
LDFLAGS=-mmcu=$(CPU) -Wl,-Map=mapfile.map
OBJS=snes2ps.o
PROG=snes2ps
# RSTDISBL WDTON SPIEN CKOPT EESAVE BOOTSZ1 BOOTSZ0 BOOTRST
# 1 1 0 1 1 0 0 1
HFUSE=0xd9
# BODLEVEL BODEN SUT1 SUT0 CKSEL3 CKSEL2 CKSEL1 CKSEL0
# 1 1 1 0 0 1 0 0
#
# Note: Uses internal 8MHz RC Oscillator
LFUSE=0xE4
all: $(PROG).hex
clean:
rm -f $(PROG).elf $(PROG).hex $(PROG).map $(OBJS)
$(PROG).elf: $(OBJS)
$(LD) $(OBJS) $(LDFLAGS) -o $(PROG).elf
$(PROG).hex: $(PROG).elf
avr-objcopy -j .data -j .text -O ihex $(PROG).elf $(PROG).hex
avr-size $(PROG).elf
flash: $(PROG).hex
$(AVRDUDE) -Uflash:w:$< -B 5.0 -e
fuse:
$(AVRDUDE) -e -Uhfuse:w:$(HFUSE):m -Ulfuse:w:$(LFUSE):m -B 20.0 -F
erase:
$(AVRDUDE) -B 10.0 -e
reset:
$(AVRDUDE) -B 10.0
%.o: %.S
$(CC) $(CFLAGS) -c $<
%.o: %.c
$(CC) $(CFLAGS) -c $<
%.o: %.c %.h
$(CC) $(CFLAGS) -c $<