Subversion Repositories group.electronics

Rev

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

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