Automatisation avec make (chargement série):
export CC = avr-gcc
export LD = avr-gcc
export MCU = atmega328p
export FCPU = 16000000
export TARGET_ARCH = -mmcu=$(MCU)
export CFLAGS = -Wall -I. -DF_CPU=$(FCPU) -Os
export LDFLAGS = -g $(TARGET_ARCH) -lm -Wl,--gc-sections
TERM = /dev/ttyACM0
PGMERISP = -c stk500v1 -b 115200 -P $(TERM)
export DUDE = /usr/bin/avrdude -F -v -p $(MCU)
TARGET = timer
C_SRC = $(wildcard *.c)
OBJS = $(C_SRC:.c=.o)
all: $(TARGET).hex
clean:
rm -f $(TARGET).o $(TARGET).hex $(TARGET).elf
$(TARGET).elf: $(OBJS)
$(LD) $(LDFLAGS) -o $@ $(OBJS)
$(TARGET).hex: $(TARGET).elf
avr-objcopy -j .text -j .data -O ihex $(TARGET).elf $(TARGET).hex
upload: $(TARGET).hex
stty -F $(TERM) hupcl # reset
$(DUDE) $(PGMERISP) -U flash:w:$(TARGET).hex
size: $(TARGET).elf
avr-size --format=avr --mcu=$(MCU) $(TARGET).elf