From 39e535df0eebf639f7deffb8f35b827f0373494a Mon Sep 17 00:00:00 2001 From: Maix0 <39835848+Maix0@users.noreply.github.com> Date: Mon, 13 Apr 2026 11:38:30 +0200 Subject: [PATCH] feat(ex00): Full ex00 --- .gitignore | 3 +++ ex00/Makefile | 42 ++++++++++++++++++++++++++++++++++++++++++ ex00/main.c | 1 + 3 files changed, 46 insertions(+) create mode 100644 .gitignore create mode 100644 ex00/Makefile create mode 100644 ex00/main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..06776cb --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.o +*.hex +*.bin diff --git a/ex00/Makefile b/ex00/Makefile new file mode 100644 index 0000000..bde88b0 --- /dev/null +++ b/ex00/Makefile @@ -0,0 +1,42 @@ +# Makefile +MCU=atmega328p +F_CPU=16000000 +CC=avr-gcc +OBJCOPY=avr-objcopy +CFLAGS=-nostdlib -std=c99 -Wall -Wextra -g -Os -mmcu=$(MCU) -DF_CPU=$(F_CPU) -I. +TARGET=main +SERIAL=-P /dev/ttyUSB0 -b 115200 + +SRC_DIR=. +OBJ_DIR=build + +SRC_FILES=main.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 $< $@ diff --git a/ex00/main.c b/ex00/main.c new file mode 100644 index 0000000..b552c8e --- /dev/null +++ b/ex00/main.c @@ -0,0 +1 @@ +int main(void) {}