Subversion Repositories group.electronics

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
122 pfowler 1
 
128 pfowler 2
DEVICE=attiny4313
3
F_CPU=8000000
122 pfowler 4
HFUSE=0xdf
128 pfowler 5
LFUSE=0xe4
122 pfowler 6
 
7
HDUSE=0xdf	# Default fuses for device
128 pfowler 8
LDUSE=0x64
122 pfowler 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)
128 pfowler 16
#COMPILE = avr-gcc  -Wall -Os -DDEBUG_LEVEL=0  -mmcu=$(DEVICE) $(INCLUDES) $(VALUES)
122 pfowler 17
 
128 pfowler 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
127 pfowler 22
OBJECTS += lib/avrutil.o 
128 pfowler 23
OBJECTS += lib/hc595.o
24
OBJECTS += lib/usiTwiSlave.o
25
OBJECTS += lib/twires.o
122 pfowler 26
 
128 pfowler 27
#OBJECTS += lib/uart.o 
28
#OBJECTS += lib/twi.o 
29
#OBJECTS += lib/wire.o 
30
#OBJECTS += lib/lcd.o 
127 pfowler 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
 
128 pfowler 37
#OBJECTS += lib/lmd.o 
127 pfowler 38
 
122 pfowler 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)
127 pfowler 52
	$(COMPILE) -o main.bin $(OBJECTS) -lm
122 pfowler 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
128 pfowler 57
	./checksize main.bin 4096 256
122 pfowler 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
	$(AVRDUDE) -U flash:w:main.hex:i
71
 
72
fuse:
73
	$(AVRDUDE) -U hfuse:w:$(HFUSE):m -U lfuse:w:$(LFUSE):m
74
 
75
fusedef:
76
	$(AVRDUDE) -U hfuse:w:$(HDUSE):m -U lfuse:w:$(LDUSE):m
77
 
78
readcal:
128 pfowler 79
	$(AVRDUDE) -U calibration:r:/dev/stdout:i | head -1