aboutsummaryrefslogtreecommitdiff
path: root/armen.mak
diff options
context:
space:
mode:
authorOtto Mattik <otto@mattik.org>2021-07-08 18:10:55 +0200
committerOtto Mattik <otto@mattik.org>2021-07-08 18:10:55 +0200
commitda34d97efb21719b2b332f8c60b2750d11bcde1f (patch)
tree2de9fe89f6d79b8ebfcde64c5e86204e904aedf2 /armen.mak
downloadarmen-a861fb554ced7709555d2d1b639c534e3f45a83f.tar.gz
armen-a861fb554ced7709555d2d1b639c534e3f45a83f.zip
git: update to v1.0HEADv1.0master
Diffstat (limited to 'armen.mak')
-rw-r--r--armen.mak125
1 files changed, 125 insertions, 0 deletions
diff --git a/armen.mak b/armen.mak
new file mode 100644
index 0000000..628c7f8
--- /dev/null
+++ b/armen.mak
@@ -0,0 +1,125 @@
+# directory of armen files
+ifndef ARMEN_DIR
+ $(eval ARMEN_DIR = $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))))
+endif
+
+# arduino uno by default
+ifndef T_CPU
+ MODEL = arduino
+ T_CPU = atmega328p
+ F_CPU = 16000000UL
+endif
+
+# cpu target
+ifeq ($(T_CPU), $(filter $(T_CPU), atiny84 attiny841 atiny85 attiny1634 atmega328p atmega2560))
+ TARGET = avr
+else
+ $(error Unknown cpu target '$(T_CPU)')
+endif
+
+# directory for compilation
+ifndef BUILD_DIR
+ BUILD_DIR = $(ARMEN_DIR)/build/armen/$(T_CPU)
+ $(warning BUILD_DIR not defined, set to $(BUILD_DIR))
+endif
+
+# tools for target
+include $(ARMEN_DIR)/$(TARGET)/tools.mak
+
+# arduino boards
+ifeq ($(MODEL), arduino)
+ ARMEN_FLAGS += -DARDUINO
+ CFLAGS += -Wl,-u,vfprintf -lprintf_min
+ ifdef UART
+ $(eval UART = $(shell expr $(UART) + 1))
+ else
+ UART = 1
+ endif
+endif
+
+# armen core files
+ARMEN_OBJS = $(BUILD_DIR)/mdep.o $(BUILD_DIR)/armen.o
+ARMEN_CORE_S = $(ARMEN_DIR)/mdep.S $(ARMEN_DIR)/$(TARGET)/core.S
+ARMEN_CORE_C = $(ARMEN_DIR)/armen.c $(ARMEN_DIR)/core.c\
+ $(ARMEN_DIR)/thread.c $(ARMEN_DIR)/gpio.c $(ARMEN_DIR)/$(TARGET)/gpio.c
+
+# option: all thread functions
+ifdef FULL_THREAD
+ ifneq ($(FULL_THREAD), 0)
+ ARMEN_FLAGS += -DUSE_FULL_THREAD
+ endif
+endif
+
+# option: max count of thread(s)
+ifdef THREAD
+ ifneq ($(THREAD), 0)
+ ARMEN_FLAGS += -DTHREAD=$(THREAD)
+ endif
+endif
+
+# option: size of timer(s)
+ifdef BIG_TIMER
+ ifneq ($(BIG_TIMER), 0)
+ ARMEN_FLAGS += -DUSE_BIG_TIMER
+ endif
+endif
+
+# option: count of timer(s)
+ifdef TIMER
+ ifeq ($(TIMER), 2)
+ ARMEN_FLAGS += -DTIMER=$(TIMER)
+ endif
+endif
+
+# option: use semaphore
+ifdef SEM
+ ifneq ($(SEM), 0)
+ ARMEN_FLAGS += -DUSE_SEM
+ ARMEN_CORE_C += $(ARMEN_DIR)/sem.c
+ endif
+endif
+
+# option: count of uart(s)
+ifdef UART
+ ifneq ($(UART), 0)
+ ARMEN_FLAGS += -DUART=$(UART)
+ ARMEN_CORE_C += $(ARMEN_DIR)/uart.c $(ARMEN_DIR)/$(TARGET)/uart.c\
+ $(ARMEN_DIR)/$(TARGET)/usart.c $(ARMEN_DIR)/$(TARGET)/usi.c
+ endif
+endif
+
+# option: use analog conversion
+ifdef ADC
+ ifneq ($(ADC), 0)
+ ARMEN_FLAGS += -DUSE_ADC
+ ARMEN_CORE_C += $(ARMEN_DIR)/$(TARGET)/adc.c
+ endif
+endif
+
+# option: use pulse with modulation
+ifdef PWM
+ ifneq ($(PWM), 0)
+ ARMEN_FLAGS += -DUSE_PWM
+ ARMEN_CORE_C += $(ARMEN_DIR)/$(TARGET)/pwm.c
+ endif
+endif
+
+# option: use [pin change] interruption(s)
+ifdef PCINT
+ ifneq ($(PCINT), 0)
+ ARMEN_FLAGS += -DUSE_PCINT
+ ARMEN_CORE_C += $(ARMEN_DIR)/$(TARGET)/pcint.c
+ ifeq ($(PCINT), 2)
+ ARMEN_FLAGS += -DPCINT_PER_PORT
+ endif
+ endif
+endif
+
+# build armen core
+$(BUILD_DIR)/mdep.o: $(ARMEN_CORE_S)
+ @if [ ! -d $(BUILD_DIR) ]; then mkdir -p $(BUILD_DIR); fi
+ $(CC) $(ASFLAGS) $(ARMEN_FLAGS) -I$(ARMEN_DIR) -c -o $@ $<
+
+$(BUILD_DIR)/armen.o: $(ARMEN_CORE_C) $(ARMEN_DIR)/armen.h $(ARMEN_DIR)/core.h
+ @if [ ! -d $(BUILD_DIR) ]; then mkdir -p $(BUILD_DIR); fi
+ $(CC) -Wno-int-conversion $(CFLAGS) $(ARMEN_FLAGS) -I$(ARMEN_DIR) -c -o $@ $<