1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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 $@ $<
|