Subversion Repositories group.electronics

Rev

Rev 22 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
20 pfowler 1
# WinAVR cross-compiler toolchain is used here
2
CC = avr-gcc
3
OBJCOPY = avr-objcopy
4
DUDE = avrdude
5
 
6
# If you are not using ATtiny2313 and the USBtiny programmer, 
7
# update the lines below to match your configuration
8
CFLAGS = -Wall -Os -Iusbdrv -I. -mmcu=atmega168a
9
OBJFLAGS = -j .text -j .data -O ihex
10
DUDEFLAGS = -p atmega168a -P usb -c avrispmkii -v
11
 
12
# Object files for the firmware (usbdrv/oddebug.o not strictly needed I think)
13
OBJECTS = usbdrv/usbdrv.o usbdrv/oddebug.o usbdrv/usbdrvasm.o main.o
14
 
15
# Command-line client
16
CMDLINE = usbtest
17
 
18
# By default, build the firmware and command-line client, but do not flash
19
#all: main.hex $(CMDLINE)
20
all: main.hex 
21
 
22
# With this, you can flash the firmware by just typing "make flash" on command-line
23
flash: main.hex
24
	$(DUDE) $(DUDEFLAGS) -U flash:w:$<
25
 
26
# One-liner to compile the command-line client from usbtest.c
27
$(CMDLINE): usbtest.c
28
	gcc -I ./libusb/include -L ./libusb/lib/gcc -O -Wall usbtest.c -o usbtest -lusb
29
 
30
# Housekeeping if you want it
31
clean:
32
	$(RM) *.o *.hex *.elf usbdrv/*.o usbtest
33
 
34
# From .elf file to .hex
35
%.hex: %.elf
36
	$(OBJCOPY) $(OBJFLAGS) $< $@
37
 
38
# Main.elf requires additional objects to the firmware, not just main.o
39
main.elf: $(OBJECTS)
40
	$(CC) $(CFLAGS) $(OBJECTS) -o $@
41
 
42
# Without this dependance, .o files will not be recompiled if you change 
43
# the config! I spent a few hours debugging because of this...
44
$(OBJECTS): usbconfig.h
45
 
46
# From C source to .o object file
47
%.o: %.c	
48
	$(CC) $(CFLAGS) -c $< -o $@
49
 
50
# From assembler source to .o object file
51
%.o: %.S
52
	$(CC) $(CFLAGS) -x assembler-with-cpp -c $< -o $@