Subversion Repositories group.NITPanels

Rev

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

#HW_VERSION=0x01
HW_VERSION=0x02
F_CPU=8000000

ifeq ($(HW_VERSION),0x01)
        DEVICE=attiny24
        HFUSE=0xdf
        LFUSE=0xe2
        HDUSE=0xdf      # Default fuses for device attiny24
        LDUSE=0x62
        DEVMEM=2048
        DEVPRG=256
endif

ifeq ($(HW_VERSION),0x02)
        DEVICE=attiny4313
        HFUSE=0xdf
        LFUSE=0xe4
        HDUSE=0xdf      # Default fuses for device attiny24
        LDUSE=0x62
        DEVMEM=4096
        DEVPRG=256
endif



PROGTYPE=avrispmkii
PROGPORT=usb

INCLUDES=-I. -I./lib/
VALUES=-DF_CPU=$(F_CPU) -DHW_VERSION=$(HW_VERSION)
AVRDUDE = avrdude -c $(PROGTYPE) -P $(PROGPORT) -p $(DEVICE)
#COMPILE = avr-gcc  -Wall -Os -DDEBUG_LEVEL=0  -mmcu=$(DEVICE) $(INCLUDES) $(VALUES)

# Use this one to trip out unused functions
COMPILE = avr-gcc -mtiny-stack  -Wall -Wl,-gc-section -fdata-sections -ffunction-sections -Os -DDEBUG_LEVEL=0  -mmcu=$(DEVICE) $(INCLUDES) $(VALUES)

OBJECTS = main.o
OBJECTS += lib/avrutil.o 
OBJECTS += lib/hc595.o
OBJECTS += lib/usiTwiSlave.o
OBJECTS += lib/twires.o

# Compiling:
all:    main.hex

.c.o:
        $(COMPILE) -c $< -o $@

.S.o:
        $(COMPILE) -x assembler-with-cpp -c $< -o $@

.c.s:
        $(COMPILE) -S $< -o $@

main.bin:       $(OBJECTS)
        $(COMPILE) -o main.bin $(OBJECTS) -lm

main.hex:       main.bin
        rm -f main.hex main.eep.hex
        avr-objcopy -j .text -j .data -O ihex main.bin main.hex
        ./checksize main.bin $(DEVMEM) $(DEVPRG)
# do the checksize script as our last action to allow successful compilation
# on Windows with WinAVR where the Unix commands will fail.

disasm: main.bin
        avr-objdump -d main.bin


clean:
        rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.bin *.o lib/*.o main.s
        
# Functions interfacing to the device
flash:  all
        sudo $(AVRDUDE) -U flash:w:main.hex:i

fuse:
        sudo $(AVRDUDE) -U hfuse:w:$(HFUSE):m -U lfuse:w:$(LFUSE):m

fusedef:
        sudo $(AVRDUDE) -U hfuse:w:$(HDUSE):m -U lfuse:w:$(LDUSE):m 

readcal:
        sudo $(AVRDUDE) -U calibration:r:/dev/stdout:i | head -1
        
readfuse:
        sudo $(AVRDUDE) -U lfuse:r:-:h -U hfuse:r:-:h -U efuse:r:-:h -U lock:r:-:h