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.
This commit is contained in:
Dave 2019-12-24 21:54:35 -06:00
parent 4923433c10
commit f0772180cb
14 changed files with 156 additions and 26 deletions

View File

@ -40,6 +40,7 @@
#include <stdint.h>
#include "asdf_config.h"
#include "asdf_arch.h"
#include "asdf_keymap_defs.h"
static volatile uint8_t tick = 0;

View File

@ -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 <https://www.gnu.org/licenses/>.
// 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 <stdint.h>
#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.
//

View File

@ -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)

View File

@ -24,13 +24,17 @@
// this program. If not, see <https://www.gnu.org/licenses/>.
#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 ASDF_NUM_ROWS 8
#define ASDF_NUM_COLS 8
#define ASCII_PLAIN_MAP \
{ \
{ ACTION_NOTHING, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, \
@ -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.

View File

@ -21,13 +21,16 @@
// this program. If not, see <https://www.gnu.org/licenses/>.
#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 ASDF_NUM_ROWS 8
#define ASDF_NUM_COLS 8
#define ASCII_PLAIN_MAP \
{ \
{ ACTION_NOTHING, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, \
@ -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.

View File

@ -24,13 +24,16 @@
// "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 ASDF_NUM_ROWS 8
#define ASDF_NUM_COLS 8
#define ASCII_PLAIN_MAP \
{ \
{ ACTION_CAPS, ACTION_SHIFT, ACTION_SHIFT, ACTION_NOTHING, \
@ -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.

View File

@ -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

View File

@ -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)

View File

@ -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"

View File

@ -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.

View File

@ -23,7 +23,7 @@
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <https://www.gnu.org/licenses/>.
//
#include <stdint.h>
#include "asdf_actions.h"
#include "asdf_arch.h"

View File

@ -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];

View File

@ -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"

View File

@ -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'