Add support for darter keyboard

This commit is contained in:
Jeremy Soller 2019-12-16 16:26:42 -07:00
parent c9182c3a06
commit c75945e943
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1
7 changed files with 222 additions and 17 deletions

View File

@ -1,12 +1,6 @@
#include <board/gpio.h>
#include <common/debug.h>
#define GPIO_ALT 0x00
#define GPIO_IN 0x80
#define GPIO_OUT 0x40
#define GPIO_UP 0x04
#define GPIO_DOWN 0x02
void gpio_init() {
// Enable LPC reset on GPD2
GCR = 0x04;
@ -62,12 +56,12 @@ void gpio_init() {
GPCRC1 = GPIO_IN | GPIO_UP;
// SMD_VGA_THERM
GPCRC2 = GPIO_IN | GPIO_UP;
// NC
GPCRC3 = GPIO_IN | GPIO_UP;
// KSO16 (Darter)
GPCRC3 = GPIO_IN;
// CNVI_DET#
GPCRC4 = GPIO_OUT | GPIO_UP;
// NC
GPCRC5 = GPIO_OUT | GPIO_UP;
// KSO17 (Darter)
GPCRC5 = GPIO_IN;
// PM_PWROK
GPCRC6 = GPIO_OUT;
// LED_ACIN

View File

@ -3,6 +3,12 @@
#include <ec/gpio.h>
#define GPIO_ALT 0x00
#define GPIO_IN 0x80
#define GPIO_OUT 0x40
#define GPIO_UP 0x04
#define GPIO_DOWN 0x02
void gpio_init(void);
void gpio_debug(void);

View File

@ -3,8 +3,8 @@
#include <stdint.h>
// Keymap output pins
#define KM_OUT 16
// Keymap output pins (16 for galago, 18 for darter)
#define KM_OUT 18
// Keymap input pins
#define KM_IN 8
// Keymap layers (normal, Fn)

View File

@ -1,6 +1,7 @@
#include <mcs51/8052.h>
#include <arch/delay.h>
#include <board/gpio.h>
#include <board/kbc.h>
#include <board/kbscan.h>
#include <board/keymap.h>
@ -15,11 +16,12 @@ void kbscan_init(void) {
// Set all outputs to GPIO mode, low, and inputs
KSOL = 0;
KSOH1 = 0;
KSOLGCTRL = 0xFF;
KSOLGOEN = 0;
KSOH1 = 0;
KSOHGCTRL = 0xFF;
KSOHGOEN = 0;
KSOH2 = 0;
// Make sure timer 2 is stopped
T2CON = 0;
@ -42,12 +44,27 @@ void kbscan_event(void) {
for (i = 0; i < KM_OUT; i++) {
// Set current line as output
if (i < 8) {
KSOLGOEN = 0;
KSOLGOEN = 1 << i;
KSOHGOEN = 0;
GPCRC3 = GPIO_IN;
GPCRC5 = GPIO_IN;
} else if (i < 16) {
KSOLGOEN = 0;
KSOHGOEN = 1 << (i - 8);
GPCRC3 = GPIO_IN;
GPCRC5 = GPIO_IN;
} else if (i == 16) {
KSOLGOEN = 0;
KSOHGOEN = 0;
GPCRC3 = GPIO_OUT;
GPCRC5 = GPIO_IN;
} else if (i == 17) {
KSOLGOEN = 0;
KSOHGOEN = 0;
GPCRC3 = GPIO_IN;
GPCRC5 = GPIO_OUT;
}
GPDRC &= ~((1 << 3) | (1 << 5));
// TODO: figure out optimal delay
delay_ticks(10);
@ -81,7 +98,7 @@ void kbscan_event(void) {
}
uint16_t key = keymap(i, j, kbscan_layer);
DEBUG("KB %d, %d, %d = 0x%04X, %d\n", i, j, kbscan_layer, key, new_b);
WARN("KB %d, %d, %d = 0x%04X, %d\n", i, j, kbscan_layer, key, new_b);
switch (key & KT_MASK) {
case (KT_FN):
if (new_b) layer = 1;
@ -144,6 +161,8 @@ void kbscan_event(void) {
// Reset all lines to inputs
KSOLGOEN = 0;
KSOHGOEN = 0;
GPCRC3 = GPIO_IN;
GPCRC5 = GPIO_IN;
// TODO: figure out optimal delay
delay_ticks(10);

View File

@ -0,0 +1,186 @@
// Default layout
#define K(V) {V, V}
uint16_t __code KEYMAP[KM_OUT][KM_IN][KM_LAY] = {
{ // 0
K(0), // 0
K(0), // 1
K(0), // 2
K(0), // 3
K(0), // 4
K(0), // 5
K(K_LEFT_CTRL), // 6
K(K_RIGHT_CTRL), // 7
},
{ // 1
K(0), // 0
K(0), // 1
K(0), // 2
K(0), // 3
K(0), // 4
K(0), // 5
K(K_LEFT_ALT), // 6
K(K_RIGHT_ALT), // 7
},
{ // 2
K(0), // 0
K(0), // 1
K(0), // 2
K(0), // 3
K(0), // 4
K(0), // 5
K(K_LEFT_SHIFT), // 6
K(K_RIGHT_SHIFT), // 7
},
{ // 3
K(K_LEFT_SUPER), // 0
K(0), // 1
K(0), // 2
K(0), // 3
K(0), // 4
K(0), // 5
K(0), // 6
K(K_SPACE), // 7
},
{ // 4
K(K_Z), // 0
K(0), // 1
K(0), // 2
K(0), // 3
K(0), // 4
K(0), // 5
K(0), // 6
K(0), // 7
},
{ // 5
K(K_PGUP), // 0
K(K_W), // 1
K(0), // 2
K(0), // 3
K(0), // 4
K(0), // 5
K(0), // 6
K(K_CAPS), // 7
},
{ // 6
K(K_PGDN), // 0
K(K_MINUS), // 1
K(K_E), // 2
K(K_L), // 3
K(0), // 4
K(0), // 5
K(K_M), // 6
K(0), // 7
},
{ // 7
K(K_K), // 0
K(K_Y), // 1
K(K_0), // 2
K(K_R), // 3
K(0), // 4
K(K_SEMICOLON), // 5
K(K_TAB), // 6
K(K_ESC), // 7
},
{ // 8
K(0), // 0
K(K_J), // 1
K(K_BRACE_CLOSE), // 2
K(K_9), // 3
K(K_T), // 4
K(K_F7), // 5
K(K_8), // 6
K(K_F1), // 7
},
{ // 9
K(0), // 0
K(K_F), // 1
K(K_H), // 2
K(K_F2), // 3
K(0), // 4
K(0), // 5
K(K_QUOTE), // 6
K(K_B), // 7
},
{ // 10
K(0), // 0
K(K_COMMA), // 1
K(0), // 2
K(K_BRACE_OPEN), // 3
K(K_S), // 4
{K_F8, KT_SCI | SCI_BRIGHTNESS_DOWN}, // 5
{K_F6, K_VOLUME_UP}, // 6
K(K_2), // 7
},
{ // 11
K(0), // 0
K(K_PERIOD), // 1
K(K_7), // 2
K(K_D), // 3
K(0), // 4
K(0), // 5
K(K_1), // 6
K(K_P), // 7
},
{ // 12
K(K_BACKSLASH), // 0
K(0), // 1
K(K_A), // 2
K(K_SLASH), // 3
K(0), // 4
{K_F3, K_MUTE}, // 5
K(K_I), // 6
K(K_6), // 7
},
{ // 13
K(0), // 0
K(K_V), // 1
K(0), // 2
{K_F9, KT_SCI | SCI_BRIGHTNESS_UP}, // 3
K(K_N), // 4
K(K_O), // 5
K(K_5), // 6
{K_F5, K_VOLUME_DOWN}, // 7
},
{ // 14
K(K_Q), // 0
K(K_F10), // 1
K(0), // 2
K(K_F4), // 3
K(0), // 4
K(0), // 5
K(K_DEL), // 6
K(K_4), // 7
},
{ // 15
K(K_APP), // 0
K(K_X), // 1
K(K_ENTER), // 2
K(0), // 3
K(K_U), // 4
K(0), // 5
K(K_3), // 6
K(K_BKSP), // 7
},
{ // 16
K(K_END), // 0
K(K_HOME), // 1
K(0), // 2
K(K_UP), // 3
K(K_DOWN), // 4
K(K_TICK), // 5
{K_F11, KT_SCI | SCI_AIRPLANE_MODE}, // 6
{K_F12, KT_SCI | SCI_SUSPEND}, // 7
},
{ // 17
K(K_G), // 0
K(K_EQUALS), // 1
K(K_C), // 2
K(KT_FN), // 3
K(0), // 4
K(K_LEFT), // 5
K(K_RIGHT), // 6
K(0), // 7
},
};

View File

@ -1,4 +1,4 @@
// Default layout
// Default layout - http://www.keyboard-layout-editor.com/#/gists/6aec6d441a039b76ec0895bd6bbda68d
#define K(V) {V, V}

View File

@ -1,4 +1,4 @@
// Jeremy's layout - http://www.keyboard-layout-editor.com/#/gists/43e77d2570f1c1c210bbdd69c106f961
// Jeremy's layout - http://www.keyboard-layout-editor.com/#/gists/fe00274727fc01b78a79d79473cd547c
#define K(V) {V, V}