2017-03-31 19:34:45 +02:00
|
|
|
MCU_TARGET = atmega328p
|
|
|
|
MCU_FREQ = 16000000UL
|
|
|
|
MCU_TTY = /dev/ttyUSB0
|
|
|
|
MCU_TTY_BAUD = 57600
|
|
|
|
MCU_PROGRAMMER = arduino
|
|
|
|
|
|
|
|
PRG = main
|
2017-05-26 00:33:45 +02:00
|
|
|
OBJ = main.o
|
2017-03-31 19:34:45 +02:00
|
|
|
|
|
|
|
OPTIMIZE = -O2
|
|
|
|
DEFS = -DF_CPU=$(MCU_FREQ) -DBAUDRATE=$(MCU_TTY_BAUD)
|
|
|
|
LIBS =
|
|
|
|
# You should not have to change anything below here.
|
|
|
|
CC = avr-gcc
|
|
|
|
# Override is only needed by avr-lib build system.
|
|
|
|
override CFLAGS = -g --std=c99 -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
|
|
|
|
override LDFLAGS = -Wl,-Map,$(PRG).map
|
|
|
|
OBJCOPY = avr-objcopy
|
|
|
|
OBJDUMP = avr-objdump
|
|
|
|
|
|
|
|
all: $(PRG).elf $(PRG).asm
|
|
|
|
|
|
|
|
$(PRG).elf: $(OBJ)
|
|
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
|
|
|
|
|
|
|
|
# dependencies:
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak *.asm *.hex
|
|
|
|
rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)
|
|
|
|
|
|
|
|
lst: $(PRG).lst
|
|
|
|
|
|
|
|
%.lst: %.elf
|
|
|
|
$(OBJDUMP) -h -S $< > $@
|
|
|
|
|
|
|
|
# Rules for building the .text rom images
|
|
|
|
text: hex bin srec
|
|
|
|
|
|
|
|
hex: $(PRG).hex
|
|
|
|
|
|
|
|
bin: $(PRG).bin
|
|
|
|
|
|
|
|
%.hex: %.elf
|
|
|
|
$(OBJCOPY) -j .text -j .data -O ihex $< $@
|
|
|
|
|
|
|
|
%.bin: %.elf
|
|
|
|
$(OBJCOPY) -j .text -j .data -O binary $< $@
|
|
|
|
|
|
|
|
# to get the final asm code
|
|
|
|
|
|
|
|
%.asm: %.elf
|
|
|
|
$(OBJDUMP) -z -j .text -m avr5 -d $< > $@
|
|
|
|
|
|
|
|
reset:
|
|
|
|
avrdude -v -p$(MCU_TARGET) -c$(MCU_PROGRAMMER) -P$(MCU_TTY) -b$(MCU_TTY_BAUD)
|
|
|
|
|
|
|
|
flash: $(PRG).hex
|
|
|
|
avrdude -v -p$(MCU_TARGET) -c$(MCU_PROGRAMMER) -P$(MCU_TTY) -b$(MCU_TTY_BAUD) -u -U flash:w:$(PRG).hex
|
|
|
|
|
|
|
|
screen:
|
|
|
|
screen $(MCU_TTY) $(MCU_TTY_BAUD)
|
|
|
|
|