From 353afe87cc2577bb9404f5cd1c7e44d2b9f21f1e Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 5 Aug 2017 15:44:31 +0900 Subject: [PATCH] pana_m8: Add initial files --- keyboard/pana_m8/Makefile | 57 +++++++++++++++++++++++++++++ keyboard/pana_m8/README | 73 ++++++++++++++++++++++++++++++++++++++ keyboard/pana_m8/config.h | 32 +++++++++++++++++ keyboard/pana_m8/pana_m8.c | 71 ++++++++++++++++++++++++++++++++++++ keyboard/pana_m8/unimap.c | 50 ++++++++++++++++++++++++++ 5 files changed, 283 insertions(+) create mode 100644 keyboard/pana_m8/Makefile create mode 100644 keyboard/pana_m8/README create mode 100644 keyboard/pana_m8/config.h create mode 100644 keyboard/pana_m8/pana_m8.c create mode 100644 keyboard/pana_m8/unimap.c diff --git a/keyboard/pana_m8/Makefile b/keyboard/pana_m8/Makefile new file mode 100644 index 00000000..93f3c462 --- /dev/null +++ b/keyboard/pana_m8/Makefile @@ -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 index 00000000..c2540b75 --- /dev/null +++ b/keyboard/pana_m8/README @@ -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 index 00000000..6d626d99 --- /dev/null +++ b/keyboard/pana_m8/config.h @@ -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 index 00000000..62fdc748 --- /dev/null +++ b/keyboard/pana_m8/pana_m8.c @@ -0,0 +1,71 @@ +#include +#include +#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<