fixed all exercices
This commit is contained in:
parent
5763bbb065
commit
2f91952d78
49 changed files with 3151 additions and 24 deletions
61
ex03/Makefile
Normal file
61
ex03/Makefile
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
# Makefile
|
||||
MCU=atmega328p
|
||||
F_CPU=16000000
|
||||
CC=avr-gcc
|
||||
OBJCOPY=avr-objcopy
|
||||
WFLAGS=-Wall -Wextra
|
||||
CFLAGS=--std=c99 -g -Os -mmcu=$(MCU) -ffunction-sections -fdata-sections
|
||||
CPPFLAGS=-DF_CPU=$(F_CPU) -MMD -Iinclude
|
||||
IFLAGS=
|
||||
LDFLAGS=-Wl,--gc-sections
|
||||
TARGET=main
|
||||
SERIAL=-P /dev/ttyUSB0 -b 115200
|
||||
|
||||
SRC_DIR=src
|
||||
OBJ_DIR=build
|
||||
|
||||
SRC_FILES=main.c utils.c uart.c rgb.c i2c.c aht20.c spi.c
|
||||
OBJ_FILES=$(patsubst %.c,%.o,$(SRC_FILES))
|
||||
DEP_FILES=$(patsubst %.c,%.d,$(SRC_FILES))
|
||||
|
||||
SRC=$(addprefix $(SRC_DIR)/,$(SRC_FILES))
|
||||
OBJ=$(addprefix $(OBJ_DIR)/,$(OBJ_FILES))
|
||||
DEP=$(addprefix $(OBJ_DIR)/,$(DEP_FILES))
|
||||
|
||||
ELF_FILE=$(OBJ_DIR)/$(TARGET).elf
|
||||
HEX_FILE=$(OBJ_DIR)/$(TARGET).hex
|
||||
|
||||
all: flash
|
||||
|
||||
re: fclean all
|
||||
|
||||
fclean: clean
|
||||
rm -f $(HEX_FILE)
|
||||
rm -f $(ELF_FILE)
|
||||
clean:
|
||||
rm -rf $(OBJ_DIR)
|
||||
|
||||
hex: $(HEX_FILE)
|
||||
|
||||
flash: hex
|
||||
avrdude -p $(MCU) -c arduino -U flash:w:$(HEX_FILE):i $(SERIAL)
|
||||
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
||||
@mkdir -p $(shell dirname $@)
|
||||
$(CC) $(CPPFLAGS) $(WFLAGS) $(CFLAGS) $(IFLAGS) -c $< -o $@
|
||||
|
||||
$(ELF_FILE): $(OBJ)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o $@
|
||||
|
||||
$(HEX_FILE): $(ELF_FILE)
|
||||
$(OBJCOPY) -j .text -j .data -O ihex $< $@
|
||||
|
||||
print:
|
||||
@echo $(SRC)
|
||||
@echo $(OBJ)
|
||||
@echo $(ELF_FILE)
|
||||
@echo $(HEX_FILE)
|
||||
|
||||
-include $(DEP);
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue