Subversion Repositories group.electronics

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
122 pfowler 1
 
123 pfowler 2
DEVICE=atmega328p
128 pfowler 3
F_CPU=20000000
122 pfowler 4
HFUSE=0xdf
5
LFUSE=0xff
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)
127 pfowler 16
COMPILE = avr-gcc -Wall -Os -DDEBUG_LEVEL=0  -mmcu=$(DEVICE) $(INCLUDES) $(VALUES)
122 pfowler 17
 
127 pfowler 18
OBJECTS  = lib/uart.o 
19
OBJECTS += lib/avrutil.o 
20
OBJECTS += lib/twi.o 
21
OBJECTS += lib/wire.o 
22
OBJECTS += lib/lcd.o 
122 pfowler 23
 
127 pfowler 24
#OBJECTS += lib/e2p.o 
25
#OBJECTS += lib/mio.o 
26
#OBJECTS += lib/oled.o 
27
#OBJECTS += lib/gfx.o
28
#OBJECTS += lib/dht.o 
29
 
30
OBJECTS += lib/lmd.o 
31
OBJECTS += main.o
32
 
122 pfowler 33
# Compiling:
34
all:	main.hex
35
 
36
.c.o:
37
	$(COMPILE) -c $< -o $@
38
 
39
.S.o:
40
	$(COMPILE) -x assembler-with-cpp -c $< -o $@
41
 
42
.c.s:
43
	$(COMPILE) -S $< -o $@
44
 
45
main.bin:	$(OBJECTS)
127 pfowler 46
	$(COMPILE) -o main.bin $(OBJECTS) -lm
122 pfowler 47
 
48
main.hex:	main.bin
49
	rm -f main.hex main.eep.hex
50
	avr-objcopy -j .text -j .data -O ihex main.bin main.hex
51
	./checksize main.bin 31768 2048
52
# do the checksize script as our last action to allow successful compilation
53
# on Windows with WinAVR where the Unix commands will fail.
54
 
55
disasm:	main.bin
56
	avr-objdump -d main.bin
57
 
58
 
59
clean:
60
	rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.bin *.o lib/*.o main.s
61
 
62
# Functions interfacing to the device
63
flash:	all
64
	$(AVRDUDE) -U flash:w:main.hex:i
65
 
66
fuse:
67
	$(AVRDUDE) -U hfuse:w:$(HFUSE):m -U lfuse:w:$(LFUSE):m
68
 
69
fusedef:
70
	$(AVRDUDE) -U hfuse:w:$(HDUSE):m -U lfuse:w:$(LDUSE):m
71
 
72
readcal:
128 pfowler 73
	$(AVRDUDE) -U calibration:r:/dev/stdout:i | head -1