aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi ISHII <2170248+mtei@users.noreply.github.com>2018-12-15 14:31:56 +0900
committerDrashna Jaelre <drashna@live.com>2018-12-14 21:31:56 -0800
commit8f790948e5f7ed62b2c56e1a6aa63dae89d5c860 (patch)
tree5d934ecae5855bf3f907b0ad485e78b42d9c228a
parenta49d98e665d934c318894cfc9d9813adacd08f11 (diff)
downloadqmk_firmware-8f790948e5f7ed62b2c56e1a6aa63dae89d5c860.tar.gz
qmk_firmware-8f790948e5f7ed62b2c56e1a6aa63dae89d5c860.zip
Refactor quantum/split_common/i2c.c, quantum/split_common/serial.c (#4522)
* add temporary compile test shell script * Extended support of SKIP_VERSION to make invariant compile results during testing. * build_keyboard.mk, tmk_core/rules.mk: add LIB_SRC, QUANTUM_LIB_SRC support Support compiled object enclosed in library. e.g. ``` LIB_SRC += xxxx.c xxxx.c --> xxxx.o ---> xxxx.a ``` * remove 'ifdef/ifndef USE_I2C' from quantum/split_common/{i2c|serial}.c * add SKIP_DEBUG_INFO into tmk_core/rules.mk When SKIP_DEBUG_INFO=yes is specified, do not use the -g option at compile time. * tmk_core/rules.mk: Library object need -fno-lto * add SKIP_DEBUG_INFO=yes * remove temporary compile test shell script * add '#define SOFT_SERIAL_PIN D0' to keyboards/lets_split/rev?/config.h * quantum/split_common/serial.c: Changed not to use USE_I2C.
-rw-r--r--build_keyboard.mk6
-rw-r--r--common_features.mk6
-rw-r--r--keyboards/lets_split/rev1/config.h3
-rw-r--r--keyboards/lets_split/rev2/config.h3
-rw-r--r--keyboards/lets_split/sockets/config.h3
-rw-r--r--quantum/split_common/i2c.c3
-rw-r--r--quantum/split_common/serial.c16
-rw-r--r--tmk_core/common/command.c4
-rw-r--r--tmk_core/rules.mk36
9 files changed, 56 insertions, 24 deletions
diff --git a/build_keyboard.mk b/build_keyboard.mk
index d225fe821..b639b92d3 100644
--- a/build_keyboard.mk
+++ b/build_keyboard.mk
@@ -34,6 +34,10 @@ $(error MASTER does not have a valid value(left/right))
34 endif 34 endif
35endif 35endif
36 36
37ifdef SKIP_VERSION
38 OPT_DEFS += -DSKIP_VERSION
39endif
40
37# Determine which subfolders exist. 41# Determine which subfolders exist.
38KEYBOARD_FOLDER_PATH_1 := $(KEYBOARD) 42KEYBOARD_FOLDER_PATH_1 := $(KEYBOARD)
39KEYBOARD_FOLDER_PATH_2 := $(patsubst %/,%,$(dir $(KEYBOARD_FOLDER_PATH_1))) 43KEYBOARD_FOLDER_PATH_2 := $(patsubst %/,%,$(dir $(KEYBOARD_FOLDER_PATH_1)))
@@ -278,6 +282,7 @@ ifneq ("$(wildcard $(KEYMAP_PATH)/config.h)","")
278endif 282endif
279 283
280# # project specific files 284# # project specific files
285SRC += $(patsubst %.c,%.clib,$(LIB_SRC))
281SRC += $(KEYBOARD_SRC) \ 286SRC += $(KEYBOARD_SRC) \
282 $(KEYMAP_C) \ 287 $(KEYMAP_C) \
283 $(QUANTUM_SRC) 288 $(QUANTUM_SRC)
@@ -296,6 +301,7 @@ include $(TMK_PATH)/protocol.mk
296include $(TMK_PATH)/common.mk 301include $(TMK_PATH)/common.mk
297include bootloader.mk 302include bootloader.mk
298 303
304SRC += $(patsubst %.c,%.clib,$(QUANTUM_LIB_SRC))
299SRC += $(TMK_COMMON_SRC) 305SRC += $(TMK_COMMON_SRC)
300OPT_DEFS += $(TMK_COMMON_DEFS) 306OPT_DEFS += $(TMK_COMMON_DEFS)
301EXTRALDFLAGS += $(TMK_COMMON_LDFLAGS) 307EXTRALDFLAGS += $(TMK_COMMON_LDFLAGS)
diff --git a/common_features.mk b/common_features.mk
index 97febe2e7..73aab5d84 100644
--- a/common_features.mk
+++ b/common_features.mk
@@ -270,7 +270,7 @@ ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
270 endif 270 endif
271 OPT_DEFS += -DSPLIT_KEYBOARD 271 OPT_DEFS += -DSPLIT_KEYBOARD
272 QUANTUM_SRC += $(QUANTUM_DIR)/split_common/split_flags.c \ 272 QUANTUM_SRC += $(QUANTUM_DIR)/split_common/split_flags.c \
273 $(QUANTUM_DIR)/split_common/split_util.c \ 273 $(QUANTUM_DIR)/split_common/split_util.c
274 $(QUANTUM_DIR)/split_common/i2c.c \ 274 QUANTUM_LIB_SRC += $(QUANTUM_DIR)/split_common/i2c.c
275 $(QUANTUM_DIR)/split_common/serial.c 275 QUANTUM_LIB_SRC += $(QUANTUM_DIR)/split_common/serial.c
276endif 276endif
diff --git a/keyboards/lets_split/rev1/config.h b/keyboards/lets_split/rev1/config.h
index a8d614915..18b7cce5a 100644
--- a/keyboards/lets_split/rev1/config.h
+++ b/keyboards/lets_split/rev1/config.h
@@ -45,6 +45,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
45/* Set 0 if debouncing isn't needed */ 45/* Set 0 if debouncing isn't needed */
46#define DEBOUNCING_DELAY 5 46#define DEBOUNCING_DELAY 5
47 47
48/* serial.c configuration for split keyboard */
49#define SOFT_SERIAL_PIN D0
50
48/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ 51/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
49#define LOCKING_SUPPORT_ENABLE 52#define LOCKING_SUPPORT_ENABLE
50/* Locking resynchronize hack */ 53/* Locking resynchronize hack */
diff --git a/keyboards/lets_split/rev2/config.h b/keyboards/lets_split/rev2/config.h
index 8844e5bb8..1c0871cd1 100644
--- a/keyboards/lets_split/rev2/config.h
+++ b/keyboards/lets_split/rev2/config.h
@@ -45,6 +45,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
45/* Set 0 if debouncing isn't needed */ 45/* Set 0 if debouncing isn't needed */
46#define DEBOUNCING_DELAY 5 46#define DEBOUNCING_DELAY 5
47 47
48/* serial.c configuration for split keyboard */
49#define SOFT_SERIAL_PIN D0
50
48/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ 51/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
49#define LOCKING_SUPPORT_ENABLE 52#define LOCKING_SUPPORT_ENABLE
50/* Locking resynchronize hack */ 53/* Locking resynchronize hack */
diff --git a/keyboards/lets_split/sockets/config.h b/keyboards/lets_split/sockets/config.h
index 10d0c997e..6939d37dc 100644
--- a/keyboards/lets_split/sockets/config.h
+++ b/keyboards/lets_split/sockets/config.h
@@ -45,6 +45,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
45/* Set 0 if debouncing isn't needed */ 45/* Set 0 if debouncing isn't needed */
46#define DEBOUNCING_DELAY 5 46#define DEBOUNCING_DELAY 5
47 47
48/* serial.c configuration for split keyboard */
49#define SOFT_SERIAL_PIN D0
50
48/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ 51/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
49#define LOCKING_SUPPORT_ENABLE 52#define LOCKING_SUPPORT_ENABLE
50/* Locking resynchronize hack */ 53/* Locking resynchronize hack */
diff --git a/quantum/split_common/i2c.c b/quantum/split_common/i2c.c
index b3d7fcc68..45e958b39 100644
--- a/quantum/split_common/i2c.c
+++ b/quantum/split_common/i2c.c
@@ -7,8 +7,6 @@
7#include "i2c.h" 7#include "i2c.h"
8#include "split_flags.h" 8#include "split_flags.h"
9 9
10#if defined(USE_I2C) || defined(EH)
11
12// Limits the amount of we wait for any one i2c transaction. 10// Limits the amount of we wait for any one i2c transaction.
13// Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is 11// Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is
14// 9 bits, a single transaction will take around 90μs to complete. 12// 9 bits, a single transaction will take around 90μs to complete.
@@ -184,4 +182,3 @@ ISR(TWI_vect) {
184 // Reset everything, so we are ready for the next TWI interrupt 182 // Reset everything, so we are ready for the next TWI interrupt
185 TWCR |= (1<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN); 183 TWCR |= (1<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN);
186} 184}
187#endif
diff --git a/quantum/split_common/serial.c b/quantum/split_common/serial.c
index f34f824d7..13e58d825 100644
--- a/quantum/split_common/serial.c
+++ b/quantum/split_common/serial.c
@@ -12,18 +12,14 @@
12#include <stdbool.h> 12#include <stdbool.h>
13#include "serial.h" 13#include "serial.h"
14 14
15#ifndef USE_I2C 15#ifdef SOFT_SERIAL_PIN
16
17#ifndef SOFT_SERIAL_PIN
18 #error quantum/split_common/serial.c need SOFT_SERIAL_PIN define
19#endif
20 16
21#ifdef __AVR_ATmega32U4__ 17#ifdef __AVR_ATmega32U4__
22 // if using ATmega32U4 I2C, can not use PD0 and PD1 in soft serial. 18 // if using ATmega32U4 I2C, can not use PD0 and PD1 in soft serial.
23 #ifdef USE_I2C 19 #ifdef USE_AVR_I2C
24 #if SOFT_SERIAL_PIN == D0 || SOFT_SERIAL_PIN == D1 20 #if SOFT_SERIAL_PIN == D0 || SOFT_SERIAL_PIN == D1
25 #error Using ATmega32U4 I2C, so can not use PD0, PD1 21 #error Using ATmega32U4 I2C, so can not use PD0, PD1
26 #endif 22 #endif
27 #endif 23 #endif
28 24
29 #if SOFT_SERIAL_PIN >= D0 && SOFT_SERIAL_PIN <= D3 25 #if SOFT_SERIAL_PIN >= D0 && SOFT_SERIAL_PIN <= D3
@@ -278,4 +274,4 @@ int serial_update_buffers(void) {
278 return 0; 274 return 0;
279} 275}
280 276
281#endif 277#endif /* SOFT_SERIAL_PIN */
diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c
index f79d5a257..aab99290d 100644
--- a/tmk_core/common/command.c
+++ b/tmk_core/common/command.c
@@ -181,7 +181,11 @@ static void print_version(void)
181 print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") " 181 print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") "
182 "PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") " 182 "PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") "
183 "VER: " STR(DEVICE_VER) "\n"); 183 "VER: " STR(DEVICE_VER) "\n");
184#ifdef SKIP_VERSION
185 print("BUILD: (" __DATE__ ")\n");
186#else
184 print("BUILD: " STR(QMK_VERSION) " (" __TIME__ " " __DATE__ ")\n"); 187 print("BUILD: " STR(QMK_VERSION) " (" __TIME__ " " __DATE__ ")\n");
188#endif
185 189
186 /* build options */ 190 /* build options */
187 print("OPTIONS:" 191 print("OPTIONS:"
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk
index ce3cd83b3..2e419dd66 100644
--- a/tmk_core/rules.mk
+++ b/tmk_core/rules.mk
@@ -28,12 +28,13 @@ VPATH :=
28 28
29# Convert all SRC to OBJ 29# Convert all SRC to OBJ
30define OBJ_FROM_SRC 30define OBJ_FROM_SRC
31$(patsubst %.c,$1/%.o,$(patsubst %.cpp,$1/%.o,$(patsubst %.cc,$1/%.o,$(patsubst %.S,$1/%.o,$($1_SRC))))) 31$(patsubst %.c,$1/%.o,$(patsubst %.cpp,$1/%.o,$(patsubst %.cc,$1/%.o,$(patsubst %.S,$1/%.o,$(patsubst %.clib,$1/%.a,$($1_SRC))))))
32endef 32endef
33$(foreach OUTPUT,$(OUTPUTS),$(eval $(OUTPUT)_OBJ +=$(call OBJ_FROM_SRC,$(OUTPUT)))) 33$(foreach OUTPUT,$(OUTPUTS),$(eval $(OUTPUT)_OBJ +=$(call OBJ_FROM_SRC,$(OUTPUT))))
34 34
35# Define a list of all objects 35# Define a list of all objects
36OBJ := $(foreach OUTPUT,$(OUTPUTS),$($(OUTPUT)_OBJ)) 36OBJ := $(foreach OUTPUT,$(OUTPUTS),$($(OUTPUT)_OBJ))
37NO_LTO_OBJ := $(filter %.a,$(OBJ))
37 38
38MASTER_OUTPUT := $(firstword $(OUTPUTS)) 39MASTER_OUTPUT := $(firstword $(OUTPUTS))
39 40
@@ -81,7 +82,9 @@ CSTANDARD = -std=gnu99
81# -Wall...: warning level 82# -Wall...: warning level
82# -Wa,...: tell GCC to pass this to the assembler. 83# -Wa,...: tell GCC to pass this to the assembler.
83# -adhlns...: create assembler listing 84# -adhlns...: create assembler listing
84CFLAGS += -g$(DEBUG) 85ifndef SKIP_DEBUG_INFO
86 CFLAGS += -g$(DEBUG)
87endif
85CFLAGS += $(CDEFS) 88CFLAGS += $(CDEFS)
86CFLAGS += -O$(OPT) 89CFLAGS += -O$(OPT)
87# add color 90# add color
@@ -110,7 +113,9 @@ CFLAGS += $(CSTANDARD)
110# -Wall...: warning level 113# -Wall...: warning level
111# -Wa,...: tell GCC to pass this to the assembler. 114# -Wa,...: tell GCC to pass this to the assembler.
112# -adhlns...: create assembler listing 115# -adhlns...: create assembler listing
113CPPFLAGS += -g$(DEBUG) 116ifndef SKIP_DEBUG_INFO
117 CPPFLAGS += -g$(DEBUG)
118endif
114CPPFLAGS += $(CPPDEFS) 119CPPFLAGS += $(CPPDEFS)
115CPPFLAGS += -O$(OPT) 120CPPFLAGS += -O$(OPT)
116# to supress "warning: only initialized variables can be placed into program memory area" 121# to supress "warning: only initialized variables can be placed into program memory area"
@@ -138,7 +143,11 @@ CPPFLAGS += -Wa,-adhlns=$(@:%.o=%.lst)
138# -listing-cont-lines: Sets the maximum number of continuation lines of hex 143# -listing-cont-lines: Sets the maximum number of continuation lines of hex
139# dump that will be displayed for a given single line of source input. 144# dump that will be displayed for a given single line of source input.
140ASFLAGS += $(ADEFS) 145ASFLAGS += $(ADEFS)
141ASFLAGS += -Wa,-adhlns=$(@:%.o=%.lst),-gstabs,--listing-cont-lines=100 146ifndef SKIP_DEBUG_INFO
147 ASFLAGS += -Wa,-adhlns=$(@:%.o=%.lst),-gstabs,--listing-cont-lines=100
148else
149 ASFLAGS += -Wa,-adhlns=$(@:%.o=%.lst),--listing-cont-lines=100
150endif
142 151
143#---------------- Library Options ---------------- 152#---------------- Library Options ----------------
144# Minimalistic printf version 153# Minimalistic printf version
@@ -210,6 +219,11 @@ ALL_CFLAGS = $(MCUFLAGS) $(CFLAGS) $(EXTRAFLAGS)
210ALL_CPPFLAGS = $(MCUFLAGS) -x c++ $(CPPFLAGS) $(EXTRAFLAGS) 219ALL_CPPFLAGS = $(MCUFLAGS) -x c++ $(CPPFLAGS) $(EXTRAFLAGS)
211ALL_ASFLAGS = $(MCUFLAGS) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS) 220ALL_ASFLAGS = $(MCUFLAGS) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS)
212 221
222define NO_LTO
223$(patsubst %.a,%.o,$1): NOLTO_CFLAGS += -fno-lto
224endef
225$(foreach LOBJ, $(NO_LTO_OBJ), $(eval $(call NO_LTO,$(LOBJ))))
226
213MOVE_DEP = mv -f $(patsubst %.o,%.td,$@) $(patsubst %.o,%.d,$@) 227MOVE_DEP = mv -f $(patsubst %.o,%.td,$@) $(patsubst %.o,%.d,$@)
214 228
215 229
@@ -290,8 +304,8 @@ $1_INCFLAGS := $$(patsubst %,-I%,$$($1_INC))
290ifdef $1_CONFIG 304ifdef $1_CONFIG
291$1_CONFIG_FLAGS += $$(patsubst %,-include %,$$($1_CONFIG)) 305$1_CONFIG_FLAGS += $$(patsubst %,-include %,$$($1_CONFIG))
292endif 306endif
293$1_CFLAGS = $$(ALL_CFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) 307$1_CFLAGS = $$(ALL_CFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) $$(NOLTO_CFLAGS)
294$1_CPPFLAGS= $$(ALL_CPPFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) 308$1_CPPFLAGS= $$(ALL_CPPFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) $$(NOLTO_CFLAGS)
295$1_ASFLAGS= $$(ALL_ASFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) 309$1_ASFLAGS= $$(ALL_ASFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS)
296 310
297# Compile: create object files from C source files. 311# Compile: create object files from C source files.
@@ -321,6 +335,12 @@ $1/%.o : %.S $1/asflags.txt $1/compiler.txt | $(BEGIN)
321 $$(eval CMD=$$(CC) -c $$($1_ASFLAGS) $$< -o $$@) 335 $$(eval CMD=$$(CC) -c $$($1_ASFLAGS) $$< -o $$@)
322 @$$(BUILD_CMD) 336 @$$(BUILD_CMD)
323 337
338$1/%.a : $1/%.o
339 @mkdir -p $$(@D)
340 @$(SILENT) || printf "Archiving: $$<" | $$(AWK_CMD)
341 $$(eval CMD=$$(AR) $$@ $$<)
342 @$$(BUILD_CMD)
343
324$1/force: 344$1/force:
325 345
326$1/cflags.txt: $1/force 346$1/cflags.txt: $1/force
@@ -346,7 +366,7 @@ $(MASTER_OUTPUT)/ldflags.txt: $(MASTER_OUTPUT)/force
346 366
347 367
348# We have to use static rules for the .d files for some reason 368# We have to use static rules for the .d files for some reason
349DEPS = $(patsubst %.o,%.d,$(OBJ)) 369DEPS = $(patsubst %.o,%.d,$(patsubst %.a,%.o,$(OBJ)))
350# Keep the .d files 370# Keep the .d files
351.PRECIOUS: $(DEPS) 371.PRECIOUS: $(DEPS)
352# Empty rule to force recompilation if the .d file is missing 372# Empty rule to force recompilation if the .d file is missing
@@ -391,7 +411,7 @@ $(shell mkdir -p $(BUILD_DIR) 2>/dev/null)
391$(eval $(foreach OUTPUT,$(OUTPUTS),$(shell mkdir -p $(OUTPUT) 2>/dev/null))) 411$(eval $(foreach OUTPUT,$(OUTPUTS),$(shell mkdir -p $(OUTPUT) 2>/dev/null)))
392 412
393# Include the dependency files. 413# Include the dependency files.
394-include $(patsubst %.o,%.d,$(OBJ)) 414-include $(patsubst %.o,%.d,$(patsubst %.a,%.o,$(OBJ)))
395 415
396 416
397# Listing of phony targets. 417# Listing of phony targets.