Subversion Repositories group.electronics

Rev

Rev 49 | Blame | Compare with Previous | Last modification | View Log | RSS feed

# WinAVR cross-compiler toolchain is used here
CC = avr-gcc
OBJCOPY = avr-objcopy
DUDE = avrdude

# If you are not using ATtiny2313 and the USBtiny programmer, 
# update the lines below to match your configuration
CFLAGS = -Wall -Os -I. -mmcu=atmega168a
OBJFLAGS = -j .text -j .data -O ihex
DUDEFLAGS = -p atmega168 -P usb -c avrispmkii -v

# Object files for the firmware (usbdrv/oddebug.o not strictly needed I think)
#OBJECTS = usbdrv/usbdrv.o usbdrv/oddebug.o usbdrv/usbdrvasm.o main.o
OBJECTS = lcd.o twi.o wire.o main.o util.o

# By default, build the firmware and command-line client, but do not flash
#all: main.hex $(CMDLINE)
all: main.hex 

# With this, you can flash the firmware by just typing "make flash" on command-line
flash: main.hex
        $(DUDE) $(DUDEFLAGS) -U flash:w:$<

# Housekeeping if you want it
clean:
        $(RM) *.o *.hex *.elf 

# From .elf file to .hex
%.hex: %.elf
        $(OBJCOPY) $(OBJFLAGS) $< $@

# Main.elf requires additional objects to the firmware, not just main.o
main.elf: $(OBJECTS)
        $(CC) $(CFLAGS) $(OBJECTS) -o $@

# Without this dependance, .o files will not be recompiled if you change 
# the config! I spent a few hours debugging because of this...
$(OBJECTS): twi.h wire.h lcd.h util.h

# From C source to .o object file
%.o: %.c        
        $(CC) $(CFLAGS) -c $< -o $@

# From assembler source to .o object file
%.o: %.S
        $(CC) $(CFLAGS) -x assembler-with-cpp -c $< -o $@