Skip to content

Commit

Permalink
general: re-organise source code to allow more applications
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisstjohn committed Aug 8, 2023
1 parent 3af03ec commit 880a65e
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 18 deletions.
31 changes: 14 additions & 17 deletions soft/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ else
SILENCE :=
endif

# Where and what are we building?
ifeq ($(APPLICATION),)
APPLICATION := sample/blinky
endif
ifeq ($(TARGET_MCU),)
TARGET_MCU := attiny85
endif

# On Debian/Ubuntu, sudo apt install gcc-avr avr-libc
CC := $(SILENCE)avr-gcc
OBJCOPY := $(SILENCE)avr-objcopy
Expand All @@ -25,24 +33,13 @@ OBJSIZE := $(SILENCE)avr-size
RMDIR := $(SILENCE)rm -rf

# List source files here...
C_SRCS := \
blinky.c \
pwm.c \
task.c \
twinkle.c \
C_SRCS := $(wildcard $(APPLICATION)/*.c) \
$(wildcard lib/*.c) \
# keep this comment to consume final backslash

# Where and what are we building?
ifeq ($(TARGET_MCU),)
TARGET_MCU := attiny85
endif
# Derive .o and .d filenames from .c
OUTPUT_DIR := build-$(TARGET_MCU)
OUTPUT_FILE := $(OUTPUT_DIR)/chaserlights.elf

# Create build directory if not already there
$(shell mkdir $(OUTPUT_DIR) 2>/dev/null)

# Derive .o and .d filenames from .c
OBJS := $(C_SRCS:%.c=$(OUTPUT_DIR)/%.o)
C_DEPS := $(C_SRCS:%.c=$(OUTPUT_DIR)/%.d)

Expand All @@ -54,7 +51,6 @@ all: $(OUTPUT_FILE:.elf=.hex) $(OUTPUT_FILE:.elf=.eep) $(OUTPUT_FILE:.elf=.lss)

clean:
-$(RMDIR) $(OUTPUT_DIR)
-mkdir $(OUTPUT_DIR)

rebuild: clean build

Expand All @@ -64,9 +60,10 @@ ifeq ($(TARGET_MCU),attiny85)
CLOCK_FREQUENCY := 16500000
endif

$(OUTPUT_DIR)/%.o: src/%.c
$(OUTPUT_DIR)/%.o: %.c
@echo $<
$(CC) -iquote inc -iquote etc \
mkdir -p $(dir $@)
$(CC) -iquote inc -iquote $(APPLICATION) \
-x c -funsigned-char -funsigned-bitfields \
-DTARGET_MCU=$(TARGET_MCU) -DF_CPU=$(CLOCK_FREQUENCY)UL \
-ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -mmcu=$(TARGET_MCU) \
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion soft/test/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
:test:
- +:unittest/**
:source:
- +:../src
- +:../lib
:include:
- +:stubs
- +:../inc
Expand Down

0 comments on commit 880a65e

Please sign in to comment.