From f0772180cbdf2d834c8cbfe9726c1e8e2e09f3d4 Mon Sep 17 00:00:00 2001 From: Dave Date: Tue, 24 Dec 2019 21:54:35 -0600 Subject: [PATCH] Break out keymap definitions - Separate the "asdf_keymaps.h" files into -- "asdf_keymaps.h" which is not keymap dependent and contains keymap function prototypes -- "asdf_keymap_defs.h" which contains the keymap definitions -- Move definitions of number of rows and columns from asdf.h to keymaps_defs.h. -- keymap_defs.h is copied from the keymaps directory depending on which keymap is specified in the Makefile. -- Makefile fixes for the above changes -- Fix includes in several files to reflect the above changes. --- firmware/asdf/src/Arch/asdf_arch_atmega328p.c | 1 + firmware/asdf/src/Arch/asdf_arch_test.c | 92 +++++++++++++++++++ firmware/asdf/src/Arch/asdf_arch_test.h | 28 +++++- ...ymaps_ascii.h => asdf_keymap_defs_ascii.h} | 12 ++- ...o.h => asdf_keymap_defs_ascii_swapped_o.h} | 11 ++- ...keymaps_test.h => asdf_keymap_defs_test.h} | 11 ++- firmware/asdf/src/Makefile.app | 8 +- firmware/asdf/src/Makefile.test | 10 +- firmware/asdf/src/asdf.c | 1 + firmware/asdf/src/asdf.h | 2 - firmware/asdf/src/asdf_actions.c | 2 +- firmware/asdf/src/asdf_keymaps.c | 1 + firmware/asdf/test/test_asdf.c | 2 + firmware/asdf/test/test_asdf_keymaps.c | 1 + 14 files changed, 156 insertions(+), 26 deletions(-) create mode 100644 firmware/asdf/src/Arch/asdf_arch_test.c rename firmware/asdf/src/Keymaps/{asdf_keymaps_ascii.h => asdf_keymap_defs_ascii.h} (98%) rename firmware/asdf/src/Keymaps/{asdf_keymaps_ascii_swapped_o.h => asdf_keymap_defs_ascii_swapped_o.h} (97%) rename firmware/asdf/src/Keymaps/{asdf_keymaps_test.h => asdf_keymap_defs_test.h} (98%) diff --git a/firmware/asdf/src/Arch/asdf_arch_atmega328p.c b/firmware/asdf/src/Arch/asdf_arch_atmega328p.c index d994eb7..4ffbb26 100644 --- a/firmware/asdf/src/Arch/asdf_arch_atmega328p.c +++ b/firmware/asdf/src/Arch/asdf_arch_atmega328p.c @@ -40,6 +40,7 @@ #include #include "asdf_config.h" #include "asdf_arch.h" +#include "asdf_keymap_defs.h" static volatile uint8_t tick = 0; diff --git a/firmware/asdf/src/Arch/asdf_arch_test.c b/firmware/asdf/src/Arch/asdf_arch_test.c new file mode 100644 index 0000000..01ab3cd --- /dev/null +++ b/firmware/asdf/src/Arch/asdf_arch_test.c @@ -0,0 +1,92 @@ +// -*- mode: C; tab-width: 2 ; indent-tabs-mode: nil -*- +// +// Unfified Keyboard Project +// ASDF keyboard firmware +// +// asdf_arch.c +// +// This file contains all the architecture dependent code, including register +// setup, I/O, timers, etc. +// +// Copyright 2019 David Fenyes +// +// This program is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation, either version 3 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program. If not, see . + + +// Wiring Information: +// Chip: {Microcontroller type and version} +// +// Example: +// PIN NAME FUNCTION +// 14-19,9,10 PORTB COLUMN inputs (1 bit per column) +// 23-25 PORTC0-2 ROW outputs (row number) +// 27 PORTC4 + + +#include +#include "asdf_keymap_defs.h" +#include "asdf_config.h" +#include "asdf_arch.h" + + + +// PROCEDURE: asdf_arch_init +// INPUTS: none +// OUTPUTS: none +// +// DESCRIPTION: sets up all the hardware for the keyboard +// +// SIDE EFFECTS: see DESCRIPTION +// +// SCOPE: public +// +// COMPLEXITY: 1 +// +void asdf_arch_init(void) {} + +// PROCEDURE: asdf_arch_send_screen_clear +// INPUTS: none +// OUTPUTS: none +// +// DESCRIPTION: Toggles the SCREEN_CLEAR output. +// +// SIDE EFFECTS: see DESCRIPTION +// +// NOTES: +// +// SCOPE: public +// +// COMPLEXITY: 1 +// +void asdf_arch_send_screen_clear(void) {} + +// PROCEDURE: asdf_arch_send_reset +// INPUTS: none +// OUTPUTS: none +// +// DESCRIPTION: Toggles the SCREEN_CLEAR output. +// +// SIDE EFFECTS: see DESCRIPTION +// +// NOTES: +// +// SCOPE: public +// +// COMPLEXITY: 1 +// +void asdf_arch_send_reset(void) {} + +//-------|---------|---------+---------+---------+---------+---------+---------+ +// Above line is 80 columns, and should display completely in the editor. +// diff --git a/firmware/asdf/src/Arch/asdf_arch_test.h b/firmware/asdf/src/Arch/asdf_arch_test.h index 1915565..34d3466 100644 --- a/firmware/asdf/src/Arch/asdf_arch_test.h +++ b/firmware/asdf/src/Arch/asdf_arch_test.h @@ -26,13 +26,37 @@ #if !defined (ASDF_ARCH_H) #define ASDF_ARCH_H +#include "asdf.h" + #define FLASH #define FLASH_READ (a) (*(a)) #define FLASH_READ_MATRIX_ELEMENT(mat,row,col) (mat)[(row)][(col)] +// PROCEDURE: asdf_arch_read_row +// INPUTS: (uint8_t) row: the row number to be scanned +// OUTPUTS: returns a word containing the active (pressed) columns +// DESCRIPTION: Outputs the argument to the ROW port, then reads the column port +// and returns the value. The value is a binary representation of the keys +// pressed within the row, with 1=pressed, 0=released. +asdf_cols_t asdf_arch_read_row(uint8_t row); + +// PROCEDURE: asdf_arch_send_screen_clear +// INPUTS: none +// OUTPUTS: none +// DESCRIPTION: Toggles the SCREEN_CLEAR output. +void asdf_arch_send_screen_clear(void); + +// PROCEDURE: asdf_arch_send_reset +// INPUTS: none +// OUTPUTS: none +// DESCRIPTION: Toggles the SCREEN_CLEAR output. +void asdf_arch_send_reset(void); + +// PROCEDURE: asdf_arch_init +// INPUTS: none +// OUTPUTS: none +// DESCRIPTION: sets up all the hardware for the keyboard void asdf_arch_init(void); -void asdf_arch_tick(void); -uint8_t asdf_arch_read_row(uint8_t row); #endif // !defined (ASDF_ARCH_H) diff --git a/firmware/asdf/src/Keymaps/asdf_keymaps_ascii.h b/firmware/asdf/src/Keymaps/asdf_keymap_defs_ascii.h similarity index 98% rename from firmware/asdf/src/Keymaps/asdf_keymaps_ascii.h rename to firmware/asdf/src/Keymaps/asdf_keymap_defs_ascii.h index bb5c5d9..b22c922 100644 --- a/firmware/asdf/src/Keymaps/asdf_keymaps_ascii.h +++ b/firmware/asdf/src/Keymaps/asdf_keymap_defs_ascii.h @@ -24,14 +24,18 @@ // this program. If not, see . -#if !defined(ASDF_KEYMAPS_H) -#define ASDF_KEYMAPS_H +#if !defined(ASDF_KEYMAP_DEFS_H) +#define ASDF_KEYMAP_DEFS_H #include "asdf.h" #include "asdf_ascii.h" #include "asdf_modifiers.h" -#define ASCII_PLAIN_MAP \ + +#define ASDF_NUM_ROWS 8 +#define ASDF_NUM_COLS 8 + +#define ASCII_PLAIN_MAP \ { \ { ACTION_NOTHING, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, \ ACTION_NOTHING, ASCII_ESC, ACTION_CTRL, ASCII_BACKSLASH }, \ @@ -131,7 +135,7 @@ void asdf_keymaps_init(void); asdf_keycode_t asdf_keymaps_get_code(uint8_t row, uint8_t col, uint8_t modifier_index); -#endif /* !defined (ASDF_KEYMAPS_H) */ +#endif /* !defined (ASDF_KEYMAP_DEFS_H) */ //-------|---------|---------+---------+---------+---------+---------+---------+ // Above line is 80 columns, and should display completely in the editor. diff --git a/firmware/asdf/src/Keymaps/asdf_keymaps_ascii_swapped_o.h b/firmware/asdf/src/Keymaps/asdf_keymap_defs_ascii_swapped_o.h similarity index 97% rename from firmware/asdf/src/Keymaps/asdf_keymaps_ascii_swapped_o.h rename to firmware/asdf/src/Keymaps/asdf_keymap_defs_ascii_swapped_o.h index b14d919..3f450ad 100644 --- a/firmware/asdf/src/Keymaps/asdf_keymaps_ascii_swapped_o.h +++ b/firmware/asdf/src/Keymaps/asdf_keymap_defs_ascii_swapped_o.h @@ -21,14 +21,17 @@ // this program. If not, see . -#if !defined(ASDF_KEYMAPS_H) -#define ASDF_KEYMAPS_H +#if !defined(ASDF_KEYMAP_DEFS_H) +#define ASDF_KEYMAP_DEFS_H #include "asdf.h" #include "asdf_ascii.h" #include "asdf_modifiers.h" -#define ASCII_PLAIN_MAP \ +#define ASDF_NUM_ROWS 8 +#define ASDF_NUM_COLS 8 + +#define ASCII_PLAIN_MAP \ { \ { ACTION_NOTHING, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, \ ACTION_NOTHING, ASCII_ESC, ACTION_CTRL, ASCII_BACKSLASH }, \ @@ -128,7 +131,7 @@ void asdf_keymaps_init(void); asdf_keycode_t asdf_keymaps_get_code(uint8_t row, uint8_t col, uint8_t modifier_index); -#endif /* !defined (ASDF_KEYMAPS_H) */ +#endif /* !defined (ASDF_KEYMAP_DEFS_H) */ //-------|---------|---------+---------+---------+---------+---------+---------+ // Above line is 80 columns, and should display completely in the editor. diff --git a/firmware/asdf/src/Keymaps/asdf_keymaps_test.h b/firmware/asdf/src/Keymaps/asdf_keymap_defs_test.h similarity index 98% rename from firmware/asdf/src/Keymaps/asdf_keymaps_test.h rename to firmware/asdf/src/Keymaps/asdf_keymap_defs_test.h index 689f28d..b596907 100644 --- a/firmware/asdf/src/Keymaps/asdf_keymaps_test.h +++ b/firmware/asdf/src/Keymaps/asdf_keymap_defs_test.h @@ -24,14 +24,17 @@ // "Shift Lock" key and a "Caps Lock" key, usually only one will be present. For // testing, both must be present to test their functionality. -#if !defined(ASDF_KEYMAPS_H) -#define ASDF_KEYMAPS_H +#if !defined(ASDF_KEYMAP_DEFS_H) +#define ASDF_KEYMAP_DEFS_H #include "asdf.h" #include "asdf_ascii.h" #include "asdf_modifiers.h" -#define ASCII_PLAIN_MAP \ +#define ASDF_NUM_ROWS 8 +#define ASDF_NUM_COLS 8 + +#define ASCII_PLAIN_MAP \ { \ { ACTION_CAPS, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, \ ACTION_NOTHING, ASCII_ESC, ACTION_CTRL, ASCII_BACKSLASH }, \ @@ -125,7 +128,7 @@ void asdf_keymaps_init(void); asdf_keycode_t asdf_keymaps_get_code(uint8_t row, uint8_t col, uint8_t modifier_index); -#endif /* !defined (ASDF_KEYMAPS_H) */ +#endif /* !defined (ASDF_KEYMAP_DEFS_H) */ //-------|---------|---------+---------+---------+---------+---------+---------+ // Above line is 80 columns, and should display completely in the editor. diff --git a/firmware/asdf/src/Makefile.app b/firmware/asdf/src/Makefile.app index fc839a3..15b0bdb 100644 --- a/firmware/asdf/src/Makefile.app +++ b/firmware/asdf/src/Makefile.app @@ -98,9 +98,9 @@ include $(wildcard $(DEPFILES)) %.o: %.c $(DEP_DIR)/%.d | $(DEP_DIR) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEPFLAGS) $< -asdf_keymaps.h: $(KEYMAPS_DIR)/asdf_keymaps_$(KEYMAP).h $(KEYMAP_H_TOKEN) +asdf_keymap_defs.h: $(KEYMAPS_DIR)/asdf_keymap_defs_$(KEYMAP).h $(KEYMAPDEFS_H_TOKEN) cp $< $@ -GENERATED_FILES += asdf_keymaps.h +GENERATED_FILES += asdf_keymap_defs.h asdf_arch.c: $(ARCH_DIR)/asdf_arch_$(ARCH).c $(ARCH_C_TOKEN) @@ -131,9 +131,9 @@ $(TARGET_BIN): $(OBJ_FILES) $(CC) $(CFLAGS) -o $@ $(LDFLAGS) $^ $(SIZE_COMMAND) $(TARGET_BIN) -asdf_keymaps.o: asdf_keymaps.c asdf.h asdf_ascii.h asdf_modifiers.h asdf_arch.h asdf_keymaps.h +asdf_keymaps.o: asdf_keymaps.c asdf.h asdf_ascii.h asdf_modifiers.h asdf_arch.h asdf_keymaps.h asdf_keymap_defs.h main.o: main.c asdf.h asdf_arch.h -asdf.o: asdf.c asdf.h asdf_arch.h asdf_keymaps.h asdf_config.h +asdf.o: asdf.c asdf.h asdf_arch.h asdf_keymaps.h asdf_config.h asdf_keymap_defs.h asdf_repeat.o: asdf_repeat.c asdf_repeat.h asdf_config.h asdf_buffer.o: asdf_buffer.c asdf.h asdf_config.h asdf_modifiers.o: asdf_modifiers.c asdf_modifiers.h diff --git a/firmware/asdf/src/Makefile.test b/firmware/asdf/src/Makefile.test index c133407..9a21dfa 100644 --- a/firmware/asdf/src/Makefile.test +++ b/firmware/asdf/src/Makefile.test @@ -33,7 +33,7 @@ CFLAGS += -Wstrict-prototypes CFLAGS += -Wundef CFLAGS += -Wold-style-definition -SRC_FILES = main.c asdf.c asdf_modifiers.c asdf_repeat.c asdf_keymaps.c asdf_buffer.c asdf_arch.c +SRC_FILES = main.c asdf.c asdf_actions.c asdf_modifiers.c asdf_repeat.c asdf_keymaps.c asdf_buffer.c asdf_arch.c OBJ_FILES = $(SRC_FILES:.c=.o) @@ -64,7 +64,7 @@ TEST4_BUILD = $(BUILD_DIR)/test_$(TEST4) TEST5 = asdf TEST5_SRC = $(TEST_DIR)/test_$(TEST5).c -TEST5_DEPS = ./$(TEST5).c $(UNITY_DIR)/unity.c ./$(TEST1).c $(TEST2).c $(TEST3).c $(TEST4).c +TEST5_DEPS = ./$(TEST5).c $(UNITY_DIR)/unity.c ./asdf_actions.c ./asdf_arch.c ./$(TEST1).c $(TEST2).c $(TEST3).c $(TEST4).c TEST5_BUILD = $(BUILD_DIR)/test_$(TEST5) .SUFFIXES: @@ -75,9 +75,9 @@ TEST5_BUILD = $(BUILD_DIR)/test_$(TEST5) all: test -asdf_keymaps.h: Keymaps/asdf_keymaps_$(KEYMAP).h +asdf_keymap_defs.h: Keymaps/asdf_keymap_defs_$(KEYMAP).h cp $< $@ -GENERATED_FILES += asdf_keymaps.h +GENERATED_FILES += asdf_keymap_defs.h asdf_arch.c: $(ARCH_DIR)/asdf_arch_$(ARCH).c _Arch_$(ARCH) @@ -92,7 +92,7 @@ GENERATED_FILES += asdf_arch.h $(ARCH_TOKEN): touch $(ARCH_TOKEN) -asdf_keymaps.c: asdf.h asdf_ascii.h asdf_modifiers.h asdf_arch.h asdf_keymaps.h +asdf_keymaps.c: asdf.h asdf_ascii.h asdf_modifiers.h asdf_arch.h asdf_keymaps.h asdf_keymap_defs.h tags: $(SRC_FILES) etags $(SRC_FILES) diff --git a/firmware/asdf/src/asdf.c b/firmware/asdf/src/asdf.c index 4b74a7f..f2ec66c 100644 --- a/firmware/asdf/src/asdf.c +++ b/firmware/asdf/src/asdf.c @@ -34,6 +34,7 @@ #include "asdf.h" #include "asdf_ascii.h" #include "asdf_keymaps.h" +#include "asdf_keymap_defs.h" #include "asdf_repeat.h" #include "asdf_modifiers.h" #include "asdf_buffer.h" diff --git a/firmware/asdf/src/asdf.h b/firmware/asdf/src/asdf.h index 8cd6e6c..df4113c 100644 --- a/firmware/asdf/src/asdf.h +++ b/firmware/asdf/src/asdf.h @@ -24,8 +24,6 @@ #if !defined(ASDF_H) #define ASDF_H -#define ASDF_NUM_ROWS 8 -#define ASDF_NUM_COLS 8 #define ASDF_ACTION 0x80 #define ASDF_INVALID_CODE ASDF_ACTION // an action code is not a valid keycode. diff --git a/firmware/asdf/src/asdf_actions.c b/firmware/asdf/src/asdf_actions.c index 9b8bc41..d8d2dd3 100644 --- a/firmware/asdf/src/asdf_actions.c +++ b/firmware/asdf/src/asdf_actions.c @@ -23,7 +23,7 @@ // You should have received a copy of the GNU General Public License along with // this program. If not, see . // - +#include #include "asdf_actions.h" #include "asdf_arch.h" diff --git a/firmware/asdf/src/asdf_keymaps.c b/firmware/asdf/src/asdf_keymaps.c index d27688e..e78d52b 100644 --- a/firmware/asdf/src/asdf_keymaps.c +++ b/firmware/asdf/src/asdf_keymaps.c @@ -24,6 +24,7 @@ #include "asdf.h" #include "asdf_arch.h" #include "asdf_keymaps.h" +#include "asdf_keymap_defs.h" typedef asdf_keycode_t keycode_matrix_t[ASDF_NUM_ROWS][ASDF_NUM_COLS]; diff --git a/firmware/asdf/test/test_asdf.c b/firmware/asdf/test/test_asdf.c index 2e99576..85cb2ba 100644 --- a/firmware/asdf/test/test_asdf.c +++ b/firmware/asdf/test/test_asdf.c @@ -4,9 +4,11 @@ #include "unity.h" #include "asdf.h" +#include "asdf_arch.h" #include "asdf_ascii.h" #include "asdf_modifiers.h" #include "asdf_keymaps.h" +#include "asdf_keymap_defs.h" #include "asdf_buffer.h" #include "asdf_repeat.h" diff --git a/firmware/asdf/test/test_asdf_keymaps.c b/firmware/asdf/test/test_asdf_keymaps.c index a17faba..447ae5a 100644 --- a/firmware/asdf/test/test_asdf_keymaps.c +++ b/firmware/asdf/test/test_asdf_keymaps.c @@ -4,6 +4,7 @@ #include "asdf_ascii.h" #include "asdf_modifiers.h" #include "asdf_keymaps.h" +#include "asdf_keymap_defs.h" #define TESTALPHA 'a' #define TESTNUM '2'