Subversion Repositories group.electronics

Rev

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

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