pana_m8: Add initial files
authortmk <hasu@tmk-kbd.com>
Sat, 5 Aug 2017 06:44:31 +0000 (15:44 +0900)
committertmk <hasu@tmk-kbd.com>
Sat, 5 Aug 2017 06:44:31 +0000 (15:44 +0900)
keyboard/pana_m8/Makefile [new file with mode: 0644]
keyboard/pana_m8/README [new file with mode: 0644]
keyboard/pana_m8/config.h [new file with mode: 0644]
keyboard/pana_m8/pana_m8.c [new file with mode: 0644]
keyboard/pana_m8/unimap.c [new file with mode: 0644]

diff --git a/keyboard/pana_m8/Makefile b/keyboard/pana_m8/Makefile
new file mode 100644 (file)
index 0000000..93f3c46
--- /dev/null
@@ -0,0 +1,57 @@
+TARGET ?= pana_m8
+TARGET_DIR ?= .
+TMK_DIR ?= ../../tmk_core
+
+MCU ?= atmega32u4
+F_CPU ?= 16000000
+# Boot Section Size in *bytes*
+OPT_DEFS += -DBOOTLOADER_SIZE=4096
+
+# LUFA specific
+ARCH ?= AVR8
+F_USB ?= $(F_CPU)
+OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
+
+
+# Build Options
+#BOOTMAGIC_ENABLE ?= yes       # Virtual DIP switch configuration
+#MOUSEKEY_ENABLE ?= yes                # Mouse keys
+#EXTRAKEY_ENABLE ?= yes                # Audio control and System control
+CONSOLE_ENABLE ?= yes          # Console for debug
+COMMAND_ENABLE ?= yes          # Commands for debug and configuration
+#NKRO_ENABLE ?= yes            # USB Nkey Rollover
+#ACTIONMAP_ENABLE ?= yes               # Use 16bit actionmap instead of 8bit keymap
+UNIMAP_ENABLE ?= yes           # Universal keymap
+KEYMAP_SECTION_ENABLE ?= yes   # fixed address keymap for keymap editor
+
+
+# List C source files
+SRC ?= pana_m8.c
+
+CONFIG_H ?= config.h
+
+
+# Keymap file
+ifeq (yes,$(strip $(UNIMAP_ENABLE)))
+    KEYMAP_FILE = unimap
+else
+    ifeq (yes,$(strip $(ACTIONMAP_ENABLE)))
+        KEYMAP_FILE = actionmap
+    else
+        KEYMAP_FILE = keymap
+    endif
+endif
+ifdef KEYMAP
+    SRC := $(KEYMAP_FILE)_$(KEYMAP).c $(SRC)
+else
+    SRC := $(KEYMAP_FILE).c $(SRC)
+endif
+
+
+# Search Path
+VPATH += $(TARGET_DIR)
+VPATH += $(TMK_DIR)
+
+include $(TMK_DIR)/protocol/lufa.mk
+include $(TMK_DIR)/common.mk
+include $(TMK_DIR)/rules.mk
diff --git a/keyboard/pana_m8/README b/keyboard/pana_m8/README
new file mode 100644 (file)
index 0000000..c2540b7
--- /dev/null
@@ -0,0 +1,73 @@
+Panasonic VP-0187A
+==================
+It is unknown keyboard from Panasonic
+
+6P6C connector
+
+Hirose Cheery M8 switches
+https://deskthority.net/wiki/Cherry_M8
+
+
+
+Scan
+----
+The keyboard is comprised of some of 4000 series IC without microcontroller.
+
+
+    RST>-----------+---------------+
+                   |               |
+            TC4520 |        TC4520 |
+            --------- carry ---------
+    CLK>--->|row    |------>|col    |
+            |counter|Q3     |counter|
+            ---------       ---------
+             Q012            Q012
+              |||             |||
+              |||             ABC   TC4028
+              |||           ---------
+              |||           |decoder|
+              |||           ---------
+              |||            |||||| col[0..7]
+              ABC            vvvvvvv   pull down
+            ---------- <----|+++++++|--100K--+
+            |data    | <----|+++++++|--100K--+
+    STATE<--|selector| <----|+++++++|--100K--+
+            | 7 to 1 | <----|+++++++|--100K--+
+            ---------- <----|+++++++|--100K--+
+                  row[0..7]                  |
+                             8x8 matrix      -
+                                            GND
+
+
+
+Matrix
+------
+        0       1       2       3       4       5       6       7
+    --------------------------------------------------------------------
+    0   ESC     1       2       3       4       5       6       7
+    1   8       9       0       -       ^       BS      INS     DEL
+    2   TAB     Q       W       E       R       T       Y       U
+    3   I       O       P       @       [       ]       F2      F1
+    4   CTRL    A       S       D       F       G       H       J
+    5   K       L       ;       :       RETURN  UP      F3      F4
+    6   SHIFT   Z       X       C       V       B       N       M
+    7   SPACE   ,       .       /       LEFT    RIGHT   DOWN    HOME
+
+
+
+6P6C connector pinout
+---------------------
+1. VCC
+2. Clock     - sends clock to binary counter TC4520
+3. Key State - indicates hi if key selected by counter is active
+4. Sense     - indicates hi if any key is active while Reset is hi.
+5. Reset     - resets counter and drives all column
+6. GND
+
+      123456
+    ,--------.
+    |        |
+    |        |
+    `--____--'
+       plug
+
diff --git a/keyboard/pana_m8/config.h b/keyboard/pana_m8/config.h
new file mode 100644 (file)
index 0000000..6d626d9
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+
+
+#define VENDOR_ID       0xFEED
+#define PRODUCT_ID      0xFFFF
+#define DEVICE_VER      0x0100
+#define MANUFACTURER    TMK.
+#define PRODUCT         Panasonic Cherry M8
+#define DESCRIPTION     TMK. keyboard firmware
+
+
+/* matrix size */
+#define MATRIX_ROWS 8
+#define MATRIX_COLS 8
+
+
+/* key combination for command */
+#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) 
+
+
+/* period of tapping(ms) */
+#define TAPPING_TERM    300
+/* tap count needed for toggling a feature */
+#define TAPPING_TOGGLE  5
+/* Oneshot timeout(ms) */
+#define ONESHOT_TIMEOUT 300
+
+/* Boot Magic salt key: Space */
+#define BOOTMAGIC_KEY_SALT      KC_SPACE
+
+#endif
diff --git a/keyboard/pana_m8/pana_m8.c b/keyboard/pana_m8/pana_m8.c
new file mode 100644 (file)
index 0000000..62fdc74
--- /dev/null
@@ -0,0 +1,71 @@
+#include <avr/io.h>
+#include <avr/pgmspace.h>
+#include "matrix.h"
+#include "led.h"
+#include "wait.h"
+#include "debug.h"
+
+#define CLK_HI() (PORTD |=  (1<<0))
+#define CLK_LO() (PORTD &= ~(1<<0))
+#define STATE()  (PIND & (1<<1))
+#define RST_HI() (PORTD |=  (1<<3))
+#define RST_LO() (PORTD &= ~(1<<3))
+#define SENSE()  (PIND & (1<<2))
+
+static matrix_row_t matrix[8] = {};
+
+
+void matrix_init(void)
+{
+    debug_enable = true;
+    debug_keyboard = true;
+    debug_matrix = true;
+
+    // PD0:Clock PD1:State PD2:Sense_All PD3:Reset(Scan_All)
+    DDRD  = (1<<3) | (1<<0);
+    PORTD = (1<<2) | (1<<1);
+
+    dprintf("init\n");
+}
+
+uint8_t matrix_scan(void)
+{
+
+    // Scan_all resets counter
+    RST_HI();
+    wait_us(10);
+    // TODO: cannot get reliable value from SENSE()
+    //uint8_t s = SENSE() | STATE();
+    //if (!SENSE()) return 0; // no activated key
+    RST_LO();
+    wait_us(10);
+    //if (!s) return 0;
+
+    // 8x8 matrix:  row:sense, col:drive, key_on:hi
+    for (uint8_t col = 0; col < 8; col++) {
+        for (uint8_t row = 0; row < 8; row++) {
+            CLK_HI();
+            wait_us(10);
+
+            if (STATE()) {
+                matrix[row] |=  (1<<col);
+            } else {
+                matrix[row] &= ~(1<<col);
+            }
+            
+            // clock lo - next row
+            CLK_LO();
+            wait_us(10);
+        }
+    }
+    return 1;
+}
+
+matrix_row_t matrix_get_row(uint8_t row)
+{
+    return matrix[row];
+}
+
+void led_set(uint8_t usb_led)
+{
+}
diff --git a/keyboard/pana_m8/unimap.c b/keyboard/pana_m8/unimap.c
new file mode 100644 (file)
index 0000000..b185a61
--- /dev/null
@@ -0,0 +1,50 @@
+#include "unimap.h"
+#include "action.h"
+#include "actionmap.h"
+#include "hook.h"
+
+
+#define UMAP( \
+    K29,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K2A,    K49,K4C,    K3A, \
+    K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K35,K2F,K30,                K3B, \
+    K78,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34,    K28,      K52,      K3C, \
+    K79,K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38,                K50,K4F,    K3D, \
+                            K2C,                                  K51,      K4A  \
+) UNIMAP ( \
+            NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO,                                     \
+    K29,    K3A,K3B,K3C,K3D,NO, NO, NO, NO, NO, NO, NO, NO,       NO, NO, NO,       NO, NO, NO, \
+    K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,NO, K2A,  K49,K4A,NO,   NO, NO, NO, NO, \
+    K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30,    NO,   K4C,NO, NO,   NO, NO, NO, NO, \
+    NO, K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34,    NO, K28,                NO, NO, NO, NO, \
+    K79,NO, K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38,    NO, NO,       K52,      NO, NO, NO, NO, \
+    K78,NO, NO, NO,         K2C,        NO, NO, NO, NO, NO, NO,   K50,K51,K4F,  NO,     NO, NO  \
+)
+
+#define AC_L1       ACTION_LAYER_MOMENTARY(1)
+
+#ifdef KEYMAP_SECTION_ENABLE
+const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
+#else
+const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = {
+#endif
+    [0] = UMAP(
+    ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,     INS, DEL,    F1,
+    TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   GRV, LBRC,RBRC,                  F2,
+    LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,         UP,       F3,
+    LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,                    LEFT,RGHT,   F4,
+                             SPC,                                                 DOWN,     HOME
+    ),
+};
+
+
+const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = {
+    { UNIMAP_ESC,     UNIMAP_1,       UNIMAP_2,       UNIMAP_3,       UNIMAP_4,       UNIMAP_5,       UNIMAP_6,       UNIMAP_7      },
+    { UNIMAP_8,       UNIMAP_9,       UNIMAP_0,       UNIMAP_MINS,    UNIMAP_EQL,     UNIMAP_BSPC,    UNIMAP_INS,     UNIMAP_DEL    },
+    { UNIMAP_TAB,     UNIMAP_Q,       UNIMAP_W,       UNIMAP_E,       UNIMAP_R,       UNIMAP_T,       UNIMAP_Y,       UNIMAP_U      },
+    { UNIMAP_I,       UNIMAP_O,       UNIMAP_P,       UNIMAP_GRV,     UNIMAP_LBRC,    UNIMAP_RBRC,    UNIMAP_F2,      UNIMAP_F1     },
+    { UNIMAP_LCTL,    UNIMAP_A,       UNIMAP_S,       UNIMAP_D,       UNIMAP_F,       UNIMAP_G,       UNIMAP_H,       UNIMAP_J      },
+    { UNIMAP_K,       UNIMAP_L,       UNIMAP_SCLN,    UNIMAP_QUOT,    UNIMAP_ENT,     UNIMAP_UP,      UNIMAP_F3,      UNIMAP_F4     },
+    { UNIMAP_LSFT,    UNIMAP_Z,       UNIMAP_X,       UNIMAP_C,       UNIMAP_V,       UNIMAP_B,       UNIMAP_N,       UNIMAP_M      },
+    { UNIMAP_SPC,     UNIMAP_COMM,    UNIMAP_DOT,     UNIMAP_SLSH,    UNIMAP_LEFT,    UNIMAP_RIGHT,   UNIMAP_DOWN,    UNIMAP_HOME   }
+};
+
Imprint / Impressum