Subversion Repositories group.electronics

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
122 pfowler 1
 
2
DEVICE=atmega168
3
F_CPU=20000000
4
HID_SIZE=44
5
 
6
AVRDUDE = avrdude -c avrispmkii -P usb -p $(DEVICE)
7
# The two lines above are for "avrdude" and the STK500 programmer connected
8
# to an USB to serial converter to a Mac running Mac OS X.
9
# Choose your favorite programmer and interface.
10
 
11
COMPILE = avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=$(DEVICE) -DF_CPU=$(F_CPU) -DHID_SIZE=$(HID_SIZE) -DDEBUG_LEVEL=0
12
# NEVER compile the final product with debugging! Any debug output will
13
# distort timing so that the specs can't be met.
14
 
15
#OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o
16
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o  main.o
17
 
18
# symbolic targets:
19
all:	main.hex
20
 
21
.c.o:
22
	$(COMPILE) -c $< -o $@
23
 
24
.S.o:
25
	$(COMPILE) -x assembler-with-cpp -c $< -o $@
26
# "-x assembler-with-cpp" should not be necessary since this is the default
27
# file type for the .S (with capital S) extension. However, upper case
28
# characters are not always preserved on Windows. To ensure WinAVR
29
# compatibility define the file type manually.
30
 
31
.c.s:
32
	$(COMPILE) -S $< -o $@
33
 
34
flash:	all
35
	$(AVRDUDE) -U flash:w:main.hex:i
36
 
37
 
38
fuse:
39
	$(AVRDUDE) -U hfuse:w:0xdf:m -U lfuse:w:0xff:m
40
 
41
fusedef:
42
	$(AVRDUDE) -U hfuse:w:0xdf:m -U lfuse:w:0x62:m
43
 
44
readcal:
45
	$(AVRDUDE) -U calibration:r:/dev/stdout:i | head -1
46
 
47
 
48
clean:
49
	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
50
 
51
# file targets:
52
main.bin:	$(OBJECTS)
53
	$(COMPILE) -o main.bin $(OBJECTS)
54
 
55
main.hex:	main.bin
56
	rm -f main.hex main.eep.hex
57
	avr-objcopy -j .text -j .data -O ihex main.bin main.hex
58
	./checksize main.bin 4096 256
59
# do the checksize script as our last action to allow successful compilation
60
# on Windows with WinAVR where the Unix commands will fail.
61
 
62
disasm:	main.bin
63
	avr-objdump -d main.bin
64
 
65
cpp:
66
	$(COMPILE) -E main.c
67
 
68
# Command-line client
69
CMDLINE = usbtest
70
 
71
# One-liner to compile the command-line client from usbtest.c
72
$(CMDLINE): usbtest.c
73
	gcc -I ./libusb/include -L ./libusb/lib/gcc -O -Wall usbtest.c -o usbtest -lusb