Subversion Repositories group.electronics

Rev

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

Rev Author Line No. Line
94 pfowler 1
DEVICE=atmega168
2
DEV_CODE=16384
3
DEV_DATA=1024
4
F_CPU=20000000
5
HID_SIZE=81
6
H_FUSE=0xdf
7
L_FUSE=0xff
33 pfowler 8
 
94 pfowler 9
HD_FUSE=0xdf
10
LD_FUSE=0x62
33 pfowler 11
 
94 pfowler 12
AVRDUDE = avrdude -c avrispmkii -P usb -p $(DEVICE)
13
 
14
COMPILE = avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=$(DEVICE) -DF_CPU=$(F_CPU) -DHID_SIZE=$(HID_SIZE) -DDEBUG_LEVEL=0
15
 
98 pfowler 16
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o main.o twi.o wire.o avrutil.o lcd.o
33 pfowler 17
 
94 pfowler 18
# symbolic targets:
19
all:	main.hex
33 pfowler 20
 
94 pfowler 21
.c.o:
22
	$(COMPILE) -c $< -o $@
33 pfowler 23
 
94 pfowler 24
.S.o:
25
	$(COMPILE) -x assembler-with-cpp -c $< -o $@
33 pfowler 26
 
94 pfowler 27
.c.s:
28
	$(COMPILE) -S $< -o $@
33 pfowler 29
 
94 pfowler 30
flash:	all
31
	$(AVRDUDE) -U flash:w:main.hex:i
32
 
33
 
34
fuse:
35
	$(AVRDUDE) -U hfuse:w:$(H_FUSE):m -U lfuse:w:$(L_FUSE):m
36
 
37
fusedef:
38
	$(AVRDUDE) -U hfuse:w:$(HD_FUSE):m -U lfuse:w:$(LD_FUSE):m
39
 
40
readcal:
41
	$(AVRDUDE) -U calibration:r:/dev/stdout:i | head -1
42
 
43
 
33 pfowler 44
clean:
94 pfowler 45
	rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.bin *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s usbtest
33 pfowler 46
 
94 pfowler 47
# file targets:
48
main.bin:	$(OBJECTS)
49
	$(COMPILE) -o main.bin $(OBJECTS)
33 pfowler 50
 
94 pfowler 51
main.hex:	main.bin
52
	rm -f main.hex main.eep.hex
53
	avr-objcopy -j .text -j .data -O ihex main.bin main.hex
98 pfowler 54
#	./checksize main.bin $(DEV_CODE) $(DEV_DATA)
94 pfowler 55
# do the checksize script as our last action to allow successful compilation
56
# on Windows with WinAVR where the Unix commands will fail.
33 pfowler 57
 
94 pfowler 58
disasm:	main.bin
59
	avr-objdump -d main.bin
33 pfowler 60
 
94 pfowler 61
cpp:
62
	$(COMPILE) -E main.c
33 pfowler 63
 
94 pfowler 64
# Command-line client
65
CMDLINE = usbtest
66
 
67
# One-liner to compile the command-line client from usbtest.c
68
$(CMDLINE): usbtest.c
69
	gcc -I ./libusb/include -L ./libusb/lib/gcc -O -Wall usbtest.c -o usbtest -lusb