Basic import
This commit is contained in:
commit
1a77421caf
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
*.o
|
||||
*.elf
|
||||
*.lst
|
||||
*.hex
|
||||
*.bin
|
||||
*.asm
|
54
Makefile
Normal file
54
Makefile
Normal file
@ -0,0 +1,54 @@
|
||||
OPTIMIZE = -O2
|
||||
CPPFLAGS += -DF_CPU=$(MCU_FREQ)
|
||||
override CFLAGS = -g --std=c99 -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET)
|
||||
override LDFLAGS =
|
||||
CC = avr-gcc
|
||||
OBJCOPY = avr-objcopy
|
||||
OBJDUMP = avr-objdump
|
||||
AVRDUDE_ARGS =
|
||||
|
||||
ifdef BOARD
|
||||
include boards/$(BOARD).mk
|
||||
endif
|
||||
|
||||
default: $(PROG).hex
|
||||
|
||||
clean:
|
||||
rm -rf *.o drivers/*.o *.elf *.lst *.hex *.bin *.asm
|
||||
|
||||
# dependencies
|
||||
blink.elf: drivers/led.o
|
||||
|
||||
# generic rules
|
||||
%.o: %.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $^
|
||||
|
||||
%.elf: %.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
|
||||
|
||||
%.lst: %.elf
|
||||
$(OBJDUMP) -h -S $< > $@
|
||||
|
||||
%.hex: %.elf
|
||||
$(OBJCOPY) -j .text -j .data -O ihex $< $@
|
||||
|
||||
%.bin: %.elf
|
||||
$(OBJCOPY) -j .text -j .data -O binary $< $@
|
||||
|
||||
%.asm: %.elf
|
||||
$(OBJDUMP) -z -j .text -m avr5 -d $< > $@
|
||||
|
||||
# flashing definitions and helper target
|
||||
AVRDUDE_ARGS += -p$(MCU_TARGET)
|
||||
AVRDUDE_ARGS += -c$(AVRDUDE_TYPE)
|
||||
ifdef AVRDUDE_TTY
|
||||
AVRDUDE_ARGS += -P$(AVRDUDE_TTY)
|
||||
endif
|
||||
ifdef AVRDUDE_BAUD
|
||||
AVRDUDE_ARGS += -b$(AVRDUDE_BAUD)
|
||||
endif
|
||||
|
||||
ifdef AVRDUDE_TYPE
|
||||
flash: $(PROG).hex
|
||||
avrdude $(AVRDUDE_ARGS) -U flash:w:$(PROG).hex
|
||||
endif
|
7
boards/nano.mk
Normal file
7
boards/nano.mk
Normal file
@ -0,0 +1,7 @@
|
||||
MCU_TARGET = atmega328p
|
||||
MCU_FREQ = 16000000UL
|
||||
CPPFLAGS += -DLED_PORT=PORTB -DLED_PIN=5
|
||||
|
||||
AVRDUDE_TYPE = arduino
|
||||
AVRDUDE_TTY = /dev/ttyUSB0
|
||||
AVRDUDE_BAUD = 57600
|
Loading…
Reference in New Issue
Block a user