Subversion Repositories group.NITPanels

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
24 pfowler 1
#HW_VERSION=0x01
2
HW_VERSION=0x02
2 pfowler 3
F_CPU=8000000
4
 
24 pfowler 5
ifeq ($(HW_VERSION),0x01)
6
	DEVICE=attiny24
7
	HFUSE=0xdf
8
	LFUSE=0xe2
9
	HDUSE=0xdf	# Default fuses for device attiny24
10
	LDUSE=0x62
11
	DEVMEM=2048
12
	DEVPRG=256
13
endif
2 pfowler 14
 
24 pfowler 15
ifeq ($(HW_VERSION),0x02)
16
	DEVICE=attiny4313
17
	HFUSE=0xdf
18
	LFUSE=0xe4
19
	HDUSE=0xdf	# Default fuses for device attiny24
20
	LDUSE=0x62
21
	DEVMEM=4096
22
	DEVPRG=256
23
endif
24
 
25
 
26
 
2 pfowler 27
PROGTYPE=avrispmkii
28
PROGPORT=usb
29
 
30
INCLUDES=-I. -I./lib/
24 pfowler 31
VALUES=-DF_CPU=$(F_CPU) -DHW_VERSION=$(HW_VERSION)
2 pfowler 32
AVRDUDE = avrdude -c $(PROGTYPE) -P $(PROGPORT) -p $(DEVICE)
33
#COMPILE = avr-gcc  -Wall -Os -DDEBUG_LEVEL=0  -mmcu=$(DEVICE) $(INCLUDES) $(VALUES)
34
 
35
# Use this one to trip out unused functions
36
COMPILE = avr-gcc -mtiny-stack  -Wall -Wl,-gc-section -fdata-sections -ffunction-sections -Os -DDEBUG_LEVEL=0  -mmcu=$(DEVICE) $(INCLUDES) $(VALUES)
37
 
38
OBJECTS = main.o
39
OBJECTS += lib/avrutil.o 
40
OBJECTS += lib/hc595.o
41
OBJECTS += lib/usiTwiSlave.o
42
OBJECTS += lib/twires.o
43
 
44
# Compiling:
45
all:	main.hex
46
 
47
.c.o:
48
	$(COMPILE) -c $< -o $@
49
 
50
.S.o:
51
	$(COMPILE) -x assembler-with-cpp -c $< -o $@
52
 
53
.c.s:
54
	$(COMPILE) -S $< -o $@
55
 
56
main.bin:	$(OBJECTS)
57
	$(COMPILE) -o main.bin $(OBJECTS) -lm
58
 
59
main.hex:	main.bin
60
	rm -f main.hex main.eep.hex
61
	avr-objcopy -j .text -j .data -O ihex main.bin main.hex
24 pfowler 62
	./checksize main.bin $(DEVMEM) $(DEVPRG)
2 pfowler 63
# do the checksize script as our last action to allow successful compilation
64
# on Windows with WinAVR where the Unix commands will fail.
65
 
66
disasm:	main.bin
67
	avr-objdump -d main.bin
68
 
69
 
70
clean:
71
	rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.bin *.o lib/*.o main.s
72
 
73
# Functions interfacing to the device
74
flash:	all
75
	sudo $(AVRDUDE) -U flash:w:main.hex:i
76
 
77
fuse:
78
	sudo $(AVRDUDE) -U hfuse:w:$(HFUSE):m -U lfuse:w:$(LFUSE):m
79
 
80
fusedef:
24 pfowler 81
	sudo $(AVRDUDE) -U hfuse:w:$(HDUSE):m -U lfuse:w:$(LDUSE):m 
2 pfowler 82
 
83
readcal:
84
	sudo $(AVRDUDE) -U calibration:r:/dev/stdout:i | head -1
85
 
86
readfuse:
87
	sudo $(AVRDUDE) -U lfuse:r:-:h -U hfuse:r:-:h -U efuse:r:-:h -U lock:r:-:h