33 |
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 atmega168 -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
|
40 |
pfowler |
14 |
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o main.o twi.o wire.o
|
33 |
pfowler |
15 |
|
|
|
16 |
# Command-line client
|
|
|
17 |
CMDLINE = usbtest
|
|
|
18 |
|
|
|
19 |
# By default, build the firmware and command-line client, but do not flash
|
|
|
20 |
#all: main.hex $(CMDLINE)
|
|
|
21 |
all: main.hex
|
|
|
22 |
|
|
|
23 |
# With this, you can flash the firmware by just typing "make flash" on command-line
|
|
|
24 |
flash: main.hex
|
|
|
25 |
$(DUDE) $(DUDEFLAGS) -U flash:w:$<
|
|
|
26 |
|
|
|
27 |
# One-liner to compile the command-line client from usbtest.c
|
|
|
28 |
$(CMDLINE): usbtest.c
|
|
|
29 |
gcc -I ./libusb/include -L ./libusb/lib/gcc -O -Wall usbtest.c -o usbtest -lusb
|
|
|
30 |
|
|
|
31 |
# Housekeeping if you want it
|
|
|
32 |
clean:
|
|
|
33 |
$(RM) *.o *.hex *.elf usbdrv/*.o usbtest
|
|
|
34 |
|
|
|
35 |
# From .elf file to .hex
|
|
|
36 |
%.hex: %.elf
|
|
|
37 |
$(OBJCOPY) $(OBJFLAGS) $< $@
|
|
|
38 |
|
|
|
39 |
# Main.elf requires additional objects to the firmware, not just main.o
|
|
|
40 |
main.elf: $(OBJECTS)
|
|
|
41 |
$(CC) $(CFLAGS) $(OBJECTS) -o $@
|
|
|
42 |
|
|
|
43 |
# Without this dependance, .o files will not be recompiled if you change
|
|
|
44 |
# the config! I spent a few hours debugging because of this...
|
40 |
pfowler |
45 |
$(OBJECTS): usbconfig.h hiddesc.h
|
33 |
pfowler |
46 |
|
|
|
47 |
# From C source to .o object file
|
|
|
48 |
%.o: %.c
|
|
|
49 |
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
50 |
|
|
|
51 |
# From assembler source to .o object file
|
|
|
52 |
%.o: %.S
|
|
|
53 |
$(CC) $(CFLAGS) -x assembler-with-cpp -c $< -o $@
|