feat(ex01): ex01 is complete
This commit is contained in:
parent
49164a0c18
commit
7eb2daf73f
5 changed files with 129 additions and 0 deletions
43
ex01/Makefile
Normal file
43
ex01/Makefile
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# Makefile
|
||||
MCU=atmega328p
|
||||
F_CPU=16000000
|
||||
CC=avr-gcc
|
||||
OBJCOPY=avr-objcopy
|
||||
CFLAGS=-std=c99 -Wall -Wextra -g -Os -mmcu=$(MCU) -DF_CPU=$(F_CPU) -Iinclude
|
||||
TARGET=main
|
||||
SERIAL=-P /dev/ttyUSB0 -b 115200
|
||||
|
||||
|
||||
SRC_DIR=.
|
||||
OBJ_DIR=build
|
||||
|
||||
SRC_FILES=main.c utils.c
|
||||
OBJ_FILES=$(patsubst %.c,%.o,$(SRC_FILES))
|
||||
|
||||
SRC=$(addprefix $(SRC_DIR)/,$(SRC_FILES))
|
||||
OBJ=$(addprefix $(OBJ_DIR)/,$(OBJ_FILES))
|
||||
|
||||
all: flash
|
||||
|
||||
re: fclean all
|
||||
|
||||
fclean: clean
|
||||
clean:
|
||||
rm -rf $(OBJ_DIR)
|
||||
rm -f $(TARGET).hex
|
||||
|
||||
hex: $(TARGET).hex
|
||||
|
||||
flash: hex
|
||||
avrdude -p $(MCU) -c arduino -U flash:w:$(TARGET).hex:i $(SERIAL)
|
||||
|
||||
$(OBJ_DIR)/$(TARGET).bin: $(OBJ)
|
||||
$(CC) $(CFLAGS) $(OBJ) -o $@
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
||||
mkdir -p $(shell dirname $@)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
|
||||
$(TARGET).hex: $(OBJ_DIR)/$(TARGET).bin
|
||||
$(OBJCOPY) -j .text -j .data -O ihex $< $@
|
||||
Loading…
Add table
Add a link
Reference in a new issue