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