aboutsummaryrefslogtreecommitdiff
path: root/keyboards/fc980c
diff options
context:
space:
mode:
authorBalz Guenat <balz.guenat@gmail.com>2017-11-23 16:34:21 +0100
committerJack Humbert <jack.humb@gmail.com>2017-11-23 10:34:21 -0500
commit2f5bb2506a6c3079ef58f2576ff48e42f0876202 (patch)
tree048cf3ef466feccc4de52a4dd6e67bf91fa23349 /keyboards/fc980c
parent3e2fd642798cde75acbecd99750e8b70eab52537 (diff)
downloadqmk_firmware-2f5bb2506a6c3079ef58f2576ff48e42f0876202.tar.gz
qmk_firmware-2f5bb2506a6c3079ef58f2576ff48e42f0876202.zip
QMK port of Hasu's fc980c alt controller (#2043)
* fc980c port, builds but yet untested. * add my own keymap
Diffstat (limited to 'keyboards/fc980c')
-rw-r--r--keyboards/fc980c/config.h84
-rw-r--r--keyboards/fc980c/fc980c.c58
-rw-r--r--keyboards/fc980c/fc980c.h76
-rw-r--r--keyboards/fc980c/keymaps/coloneljesus/README.md1
-rw-r--r--keyboards/fc980c/keymaps/coloneljesus/config.h24
-rw-r--r--keyboards/fc980c/keymaps/coloneljesus/keymap.c39
-rw-r--r--keyboards/fc980c/keymaps/default/README.md5
-rw-r--r--keyboards/fc980c/keymaps/default/config.h24
-rw-r--r--keyboards/fc980c/keymaps/default/keymap.c39
-rw-r--r--keyboards/fc980c/matrix.c228
-rw-r--r--keyboards/fc980c/rules.mk64
11 files changed, 642 insertions, 0 deletions
diff --git a/keyboards/fc980c/config.h b/keyboards/fc980c/config.h
new file mode 100644
index 000000000..a79f6f57b
--- /dev/null
+++ b/keyboards/fc980c/config.h
@@ -0,0 +1,84 @@
1/*
2Copyright 2017 Balz Guenat
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef CONFIG_H
19#define CONFIG_H
20
21#include "config_common.h"
22
23/* USB Device descriptor parameter */
24#define VENDOR_ID 0xFEED
25#define PRODUCT_ID 0x980C
26#define DEVICE_VER 0x0100
27#define MANUFACTURER QMK
28#define PRODUCT Leopold FC980C with QMK
29#define DESCRIPTION Leopold FC980C with Hasu alternative controller using QMK
30
31/* key matrix size */
32#define MATRIX_ROWS 8
33#define MATRIX_COLS 16
34
35// #define MATRIX_ROW_PINS { B0, B2, B4, B5, B6 }
36// #define MATRIX_COL_PINS { F5, B1, F0, F1, F4, B3, D7, D6, D4, D5, D3, D2, D1, D0 }
37// #define UNUSED_PINS
38
39#define DIODE_DIRECTION CUSTOM_MATRIX
40
41/* define if matrix has ghost */
42//#define MATRIX_HAS_GHOST
43
44/* number of backlight levels */
45// #define BACKLIGHT_LEVELS 1
46
47/* mapping backlight LEDs to correct Pin */
48// #define BACKLIGHT_PIN B7
49
50/* Set 0 if debouncing isn't needed */
51#define DEBOUNCING_DELAY 0
52#define TAPPING_TERM 175
53
54/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
55// #define LOCKING_SUPPORT_ENABLE
56/* Locking resynchronize hack */
57// #define LOCKING_RESYNC_ENABLE
58
59/* key combination for command */
60#define IS_COMMAND() ( \
61 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
62)
63
64
65
66/*
67 * Feature disable options
68 * These options are also useful to firmware size reduction.
69 */
70
71/* disable debug print */
72//#define NO_DEBUG
73
74/* disable print */
75//#define NO_PRINT
76
77/* disable action features */
78//#define NO_ACTION_LAYER
79//#define NO_ACTION_TAPPING
80//#define NO_ACTION_ONESHOT
81//#define NO_ACTION_MACRO
82//#define NO_ACTION_FUNCTION
83
84#endif
diff --git a/keyboards/fc980c/fc980c.c b/keyboards/fc980c/fc980c.c
new file mode 100644
index 000000000..b78243105
--- /dev/null
+++ b/keyboards/fc980c/fc980c.c
@@ -0,0 +1,58 @@
1/*
2Copyright 2017 Balz Guenat
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#include "fc980c.h"
18
19void matrix_init_kb(void) {
20 // put your keyboard start-up code here
21 // runs once when the firmware starts up
22
23 matrix_init_user();
24}
25
26void matrix_scan_kb(void) {
27 // put your looping keyboard code here
28 // runs every cycle (a lot)
29
30 matrix_scan_user();
31}
32
33bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
34 // put your per-action keyboard code here
35 // runs for every action, just before processing by the firmware
36
37 return process_record_user(keycode, record);
38}
39
40void led_set_kb(uint8_t usb_led) {
41 if (usb_led & (1<<USB_LED_NUM_LOCK)) {
42 PORTB |= (1<<4);
43 } else {
44 PORTB &= ~(1<<4);
45 }
46 if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
47 PORTB |= (1<<5);
48 } else {
49 PORTB &= ~(1<<5);
50 }
51 if (usb_led & (1<<USB_LED_SCROLL_LOCK)) {
52 PORTB |= (1<<6);
53 } else {
54 PORTB &= ~(1<<6);
55 }
56
57 led_set_user(usb_led);
58}
diff --git a/keyboards/fc980c/fc980c.h b/keyboards/fc980c/fc980c.h
new file mode 100644
index 000000000..c3992bbed
--- /dev/null
+++ b/keyboards/fc980c/fc980c.h
@@ -0,0 +1,76 @@
1/*
2Copyright 2017 Balz Guenat
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#ifndef FC980C_H
18#define FC980C_H
19
20#include "quantum.h"
21// #include "quantum_keycodes.h"
22
23/*
24----------------------------------------------------------------------------------------------------------------------
25| K0D | | K2D | K5D | K3D | K6D | | K7D | K7F | K7E | K7C | | K72 | K71 | K70 | K73 | | K74 | K76 | K77 | K75 |
26----------------------------------------------------------------------------------------------------------------------
27----------------------------------------------------------------------------------------------------------------------
28| K0A | K69 | K59 | K58 | K5B | K6F | K5F | K5E | K6C | K5C | K52 | K51 | K50 | K55 | | K54 | K56 | K57 | K65 |
29----------------------------------------------------------------------------------------------------------------------
30| K6A | K39 | K68 | K6B | K3B | K3F | K6E | K3E | K3C | K62 | K61 | K60 | K33 | K53 | | K64 | K66 | K67 | |
31---------------------------------------------------------------------------------------------------------------| K25 |
32| K3A | K29 | K38 | K28 | K2B | K2F | K2E | K2C | K1C | K32 | K31 | K20 | K63 | | K24 | K26 | K27 | |
33----------------------------------------------------------------------------------------------------------------------
34| K2A | K18 | K08 | K1B | K0B | K1F | K1E | K0E | K22 | K11 | K21 | K30 || K34 || K14 | K16 | K17 | |
35---------------------------------------------------------------------------------------------------------------| K15 |
36| K1A | K09 | K19 | K0F | K02 | K01 | K10 || K00 | K04 | K06 || K07 | K05 | |
37----------------------------------------------------------------------------------------------------------------------
38*/
39
40#define KEYMAP( \
41 K0D, K2D,K5D,K3D,K6D,K7D,K7F,K7E,K7C,K72,K71,K70,K73, K74,K76,K77,K75, \
42 K0A,K69,K59,K58,K5B,K6F,K5F,K5E,K6C,K5C,K52,K51,K50,K55, K54,K56,K57,K65, \
43 K6A,K39,K68,K6B,K3B,K3F,K6E,K3E,K3C,K62,K61,K60,K33,K53, K64,K66,K67,K25, \
44 K3A,K29,K38,K28,K2B,K2F,K2E,K2C,K1C,K32,K31,K20, K63, K24,K26,K27, \
45 K2A, K18,K08,K1B,K0B,K1F,K1E,K0E,K22,K11,K21, K30, K34, K14,K16,K17,K15, \
46 K1A,K09,K19, K0F, K02,K01,K10, K00,K04,K06, K07,K05 \
47) { \
48 { K00, K01, K02, KC_NO,K04, K05, K06, K07 , \
49 K08, K09, K0A, K0B, KC_NO,K0D, K0E, K0F }, \
50 { K10, K11, KC_NO,KC_NO,K14, K15, K16, K17 , \
51 K18, K19, K1A, K1B, K1C, KC_NO,K1E, K1F }, \
52 { K20, K21, K22, KC_NO,K24, K25, K26, K27 , \
53 K28, K29, K2A, K2B, K2C, K2D, K2E, K2F }, \
54 { K30, K31, K32, K33, K34, KC_NO,KC_NO,KC_NO , \
55 K38, K39, K3A, K3B, K3C, K3D, K3E, K3F }, \
56 { KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO , \
57 KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO }, \
58 { K50, K51, K52, K53, K54, K55, K56, K57 , \
59 K58, K59, KC_NO,K5B, K5C, K5D, K5E, K5F }, \
60 { K60, K61, K62, K63, K64, K65, K66, K67 , \
61 K68, K69, K6A, K6B, K6C, K6D, K6E, K6F }, \
62 { K70, K71, K72, K73, K74, K75, K76, K77 , \
63 KC_NO,KC_NO,KC_NO,KC_NO,K7C, K7D, K7E, K7F } \
64}
65/*
66KEYMAP(
67 _______, _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______,_______,
68 _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______,_______,
69 _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______,_______,
70 _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______,_______,_______,
71 _______, _______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______, _______,_______,_______,_______,
72 _______,_______,_______, _______, _______,_______,_______, _______,_______,_______, _______,_______
73)
74*/
75
76#endif
diff --git a/keyboards/fc980c/keymaps/coloneljesus/README.md b/keyboards/fc980c/keymaps/coloneljesus/README.md
new file mode 100644
index 000000000..d00c57e68
--- /dev/null
+++ b/keyboards/fc980c/keymaps/coloneljesus/README.md
@@ -0,0 +1 @@
# My FC980C keymap
diff --git a/keyboards/fc980c/keymaps/coloneljesus/config.h b/keyboards/fc980c/keymaps/coloneljesus/config.h
new file mode 100644
index 000000000..596198be1
--- /dev/null
+++ b/keyboards/fc980c/keymaps/coloneljesus/config.h
@@ -0,0 +1,24 @@
1/* Copyright 2017 Balz Guenat
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef CONFIG_USER_H
18#define CONFIG_USER_H
19
20#include "config_common.h"
21
22// place overrides here
23
24#endif
diff --git a/keyboards/fc980c/keymaps/coloneljesus/keymap.c b/keyboards/fc980c/keymaps/coloneljesus/keymap.c
new file mode 100644
index 000000000..d82a616eb
--- /dev/null
+++ b/keyboards/fc980c/keymaps/coloneljesus/keymap.c
@@ -0,0 +1,39 @@
1/*
2Copyright 2017 Balz Guenat
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#include "fc980c.h"
18
19const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
20 [0] = KEYMAP(
21 KC_ESC, KC_F1,KC_F2,KC_F3,KC_F4,KC_F5,KC_F6,KC_F7,KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_INS, KC_PGUP,KC_PGDN,
22 KC_GRV, KC_1,KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,KC_EQL, KC_BSPC, KC_NLCK,KC_PSLS,KC_PAST,KC_PMNS,
23 KC_TAB, KC_Q,KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,KC_RBRC,KC_BSLS, KC_P7, KC_P8, KC_P9, KC_PPLS,
24 MO(1) , KC_A,KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT, KC_ENT, KC_P4, KC_P5, KC_P6,
25 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_P1, KC_P2, KC_P3, KC_PENT,
26 KC_LCTL,KC_LGUI,KC_LALT, KC_SPC, KC_RALT,KC_RCTL,MO(1), KC_LEFT,KC_DOWN,KC_RGHT, KC_P0, KC_PDOT
27 ),
28 [1] = KEYMAP(
29 _______, _______,_______,_______,_______,_______,_______, _______, _______,_______,_______,_______,_______, _______,_______,KC_HOME,KC_END,
30 _______,_______,_______,_______,_______,_______,_______,_______, _______, _______,_______,_______,_______,_______, _______,_______,_______,_______,
31 KC_CAPS,KC_MPRV,KC_VOLU,KC_MNXT,KC_PGUP,KC_INS,KC_HOME, LCTL(KC_LEFT),LCTL(KC_RGHT),KC_END, KC_PSCR,KC_SLCK,KC_PAUS,_______, _______,_______,_______,_______,
32 _______,KC_MUTE,KC_VOLD,KC_MPLY,KC_PGDN,KC_DEL,KC_LEFT, KC_DOWN, KC_UP, KC_RGHT,_______,_______, _______, _______,_______,_______,
33 _______, _______,_______,_______,_______,_______,LCTL(KC_BSPC),LCTL(KC_DEL), _______,_______,_______, _______, KC_PGUP, _______,_______,_______,_______,
34 _______,_______,_______, _______, _______,KC_APP, _______, KC_HOME,KC_PGDN,KC_END, _______,_______
35 ),
36};
37
38const uint16_t PROGMEM fn_actions[] = {
39};
diff --git a/keyboards/fc980c/keymaps/default/README.md b/keyboards/fc980c/keymaps/default/README.md
new file mode 100644
index 000000000..103a1efc1
--- /dev/null
+++ b/keyboards/fc980c/keymaps/default/README.md
@@ -0,0 +1,5 @@
1# The default keymap for the FC980C
2
3Emulates original keymap.
4
5![](https://i.imgur.com/bQBXPkY.jpg)
diff --git a/keyboards/fc980c/keymaps/default/config.h b/keyboards/fc980c/keymaps/default/config.h
new file mode 100644
index 000000000..596198be1
--- /dev/null
+++ b/keyboards/fc980c/keymaps/default/config.h
@@ -0,0 +1,24 @@
1/* Copyright 2017 Balz Guenat
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef CONFIG_USER_H
18#define CONFIG_USER_H
19
20#include "config_common.h"
21
22// place overrides here
23
24#endif
diff --git a/keyboards/fc980c/keymaps/default/keymap.c b/keyboards/fc980c/keymaps/default/keymap.c
new file mode 100644
index 000000000..4a1872ad0
--- /dev/null
+++ b/keyboards/fc980c/keymaps/default/keymap.c
@@ -0,0 +1,39 @@
1/*
2Copyright 2017 Balz Guenat
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#include "fc980c.h"
18
19const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
20 [0] = KEYMAP(
21 KC_ESC, KC_F1,KC_F2,KC_F3,KC_F4,KC_F5,KC_F6,KC_F7,KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_INS, KC_PGUP,KC_PGDN,
22 KC_GRV, KC_1,KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,KC_EQL, KC_BSPC, KC_NLCK,KC_PSLS,KC_PAST,KC_PMNS,
23 KC_TAB, KC_Q,KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,KC_RBRC,KC_BSLS, KC_P7, KC_P8, KC_P9, KC_PPLS,
24 KC_CAPS,KC_A,KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT, KC_ENT, KC_P4, KC_P5, KC_P6,
25 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_P1, KC_P2, KC_P3, KC_PENT,
26 KC_LCTL,KC_LGUI,KC_LALT, KC_SPC, KC_RALT,KC_RCTL,MO(1), KC_LEFT,KC_DOWN,KC_RGHT, KC_P0, KC_PDOT
27 ),
28 [1] = KEYMAP(
29 _______, _______,_______,_______,_______,_______,_______,_______, _______, _______, _______,_______,_______, _______,_______,KC_HOME,KC_END,
30 _______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______, _______,_______,_______, _______,_______,_______,_______,
31 _______,_______,_______,_______,_______,_______,_______,_______,KC_PSCR, KC_SLCK, KC_PAUS, _______,_______,_______, _______,_______,_______,_______,
32 _______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______, _______, _______, _______,_______,_______,
33 _______, _______,_______,_______,_______,_______,_______,_______, _______, _______, _______, _______, KC_PGUP, _______,_______,_______,_______,
34 _______,_______,_______, _______, _______,KC_APP, _______, KC_HOME,KC_PGDN,KC_END, _______,_______
35 ),
36};
37
38const uint16_t PROGMEM fn_actions[] = {
39};
diff --git a/keyboards/fc980c/matrix.c b/keyboards/fc980c/matrix.c
new file mode 100644
index 000000000..906fec29a
--- /dev/null
+++ b/keyboards/fc980c/matrix.c
@@ -0,0 +1,228 @@
1/*
2Copyright 2017 Balz Guenat
3based on work by Jun Wako <wakojun@gmail.com>
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 2 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/*
20 * scan matrix
21 */
22#include <stdint.h>
23#include <stdbool.h>
24#include <util/delay.h>
25#include "print.h"
26#include "debug.h"
27#include "util.h"
28#include "timer.h"
29#include "matrix.h"
30#include "led.h"
31// #include "fc980c.h"
32
33
34// Timer resolution check
35#if (1000000/TIMER_RAW_FREQ > 20)
36# error "Timer resolution(>20us) is not enough for HHKB matrix scan tweak on V-USB."
37#endif
38
39
40/*
41 * Pin configuration for ATMega32U4
42 *
43 * Row: PD4-6, PD7(~EN)
44 * Col: PB0-3
45 * Key: PC6(pull-uped)
46 * Hys: PC7
47 */
48static inline void KEY_ENABLE(void) { (PORTD &= ~(1<<7)); }
49static inline void KEY_UNABLE(void) { (PORTD |= (1<<7)); }
50static inline bool KEY_STATE(void) { return (PINC & (1<<6)); }
51static inline void KEY_HYS_ON(void) { (PORTC |= (1<<7)); }
52static inline void KEY_HYS_OFF(void) { (PORTC &= ~(1<<7)); }
53static inline void KEY_INIT(void)
54{
55 /* Col */
56 DDRB |= 0x0F;
57 /* Key: input with pull-up */
58 DDRC &= ~(1<<6);
59 PORTC |= (1<<6);
60 /* Hys */
61 DDRC |= (1<<7);
62 /* Row */
63 DDRD |= 0xF0;
64
65 KEY_UNABLE();
66 KEY_HYS_OFF();
67}
68static inline void SET_ROW(uint8_t ROW)
69{
70 // PD4-6
71 PORTD = (PORTD & 0x8F) | ((ROW & 0x07) << 4);
72}
73static inline void SET_COL(uint8_t COL)
74{
75 // PB0-3
76 PORTB = (PORTB & 0xF0) | (COL & 0x0F);
77}
78
79static uint32_t matrix_last_modified = 0;
80
81// matrix state buffer(1:on, 0:off)
82static matrix_row_t *matrix;
83static matrix_row_t *matrix_prev;
84static matrix_row_t _matrix0[MATRIX_ROWS];
85static matrix_row_t _matrix1[MATRIX_ROWS];
86
87
88__attribute__ ((weak))
89void matrix_init_quantum(void) {
90 matrix_init_kb();
91}
92
93__attribute__ ((weak))
94void matrix_scan_quantum(void) {
95 matrix_scan_kb();
96}
97
98__attribute__ ((weak))
99void matrix_init_kb(void) {
100 matrix_init_user();
101}
102
103__attribute__ ((weak))
104void matrix_scan_kb(void) {
105 matrix_scan_user();
106}
107
108__attribute__ ((weak))
109void matrix_init_user(void) {
110}
111
112__attribute__ ((weak))
113void matrix_scan_user(void) {
114}
115
116
117void matrix_init(void)
118{
119 debug_enable = true;
120 debug_matrix = true;
121
122 KEY_INIT();
123
124 // LEDs on NumLock, CapsLock and ScrollLock(PB4, PB5, PB6)
125 DDRB |= (1<<4) | (1<<5) | (1<<6);
126 PORTB |= (1<<4) | (1<<5) | (1<<6);
127
128 // initialize matrix state: all keys off
129 for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00;
130 for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix1[i] = 0x00;
131 matrix = _matrix0;
132 matrix_prev = _matrix1;
133 matrix_init_quantum();
134}
135
136uint8_t matrix_scan(void)
137{
138 matrix_row_t *tmp;
139
140 tmp = matrix_prev;
141 matrix_prev = matrix;
142 matrix = tmp;
143
144 uint8_t row, col;
145 for (col = 0; col < MATRIX_COLS; col++) {
146 SET_COL(col);
147 for (row = 0; row < MATRIX_ROWS; row++) {
148 //KEY_SELECT(row, col);
149 SET_ROW(row);
150 _delay_us(2);
151
152 // Not sure this is needed. This just emulates HHKB controller's behaviour.
153 if (matrix_prev[row] & (1<<col)) {
154 KEY_HYS_ON();
155 }
156 _delay_us(10);
157
158 // NOTE: KEY_STATE is valid only in 20us after KEY_ENABLE.
159 // If V-USB interrupts in this section we could lose 40us or so
160 // and would read invalid value from KEY_STATE.
161 uint8_t last = TIMER_RAW;
162
163 KEY_ENABLE();
164
165 // Wait for KEY_STATE outputs its value.
166 _delay_us(2);
167
168 if (KEY_STATE()) {
169 matrix[row] &= ~(1<<col);
170 } else {
171 matrix[row] |= (1<<col);
172 }
173
174 // Ignore if this code region execution time elapses more than 20us.
175 // MEMO: 20[us] * (TIMER_RAW_FREQ / 1000000)[count per us]
176 // MEMO: then change above using this rule: a/(b/c) = a*1/(b/c) = a*(c/b)
177 if (TIMER_DIFF_RAW(TIMER_RAW, last) > 20/(1000000/TIMER_RAW_FREQ)) {
178 matrix[row] = matrix_prev[row];
179 }
180
181 _delay_us(5);
182 KEY_HYS_OFF();
183 KEY_UNABLE();
184
185 // NOTE: KEY_STATE keep its state in 20us after KEY_ENABLE.
186 // This takes 25us or more to make sure KEY_STATE returns to idle state.
187 _delay_us(75);
188 }
189 if (matrix[row] ^ matrix_prev[row]) {
190 matrix_last_modified = timer_read32();
191 }
192 }
193 matrix_scan_quantum();
194 return 1;
195}
196
197inline
198matrix_row_t matrix_get_row(uint8_t row) {
199 return matrix[row];
200}
201
202void matrix_print(void)
203{
204#if (MATRIX_COLS <= 8)
205 print("r/c 01234567\n");
206#elif (MATRIX_COLS <= 16)
207 print("r/c 0123456789ABCDEF\n");
208#elif (MATRIX_COLS <= 32)
209 print("r/c 0123456789ABCDEF0123456789ABCDEF\n");
210#endif
211
212 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
213
214#if (MATRIX_COLS <= 8)
215 xprintf("%02X: %08b%s\n", row, bitrev(matrix_get_row(row)),
216#elif (MATRIX_COLS <= 16)
217 xprintf("%02X: %016b%s\n", row, bitrev16(matrix_get_row(row)),
218#elif (MATRIX_COLS <= 32)
219 xprintf("%02X: %032b%s\n", row, bitrev32(matrix_get_row(row)),
220#endif
221#ifdef MATRIX_HAS_GHOST
222 matrix_has_ghost_in_row(row) ? " <ghost" : ""
223#else
224 ""
225#endif
226 );
227 }
228}
diff --git a/keyboards/fc980c/rules.mk b/keyboards/fc980c/rules.mk
new file mode 100644
index 000000000..79d40dc61
--- /dev/null
+++ b/keyboards/fc980c/rules.mk
@@ -0,0 +1,64 @@
1# MCU name
2MCU = atmega32u4
3
4# Processor frequency.
5# This will define a symbol, F_CPU, in all source code files equal to the
6# processor frequency in Hz. You can then use this symbol in your source code to
7# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
8# automatically to create a 32-bit value in your source code.
9#
10# This will be an integer division of F_USB below, as it is sourced by
11# F_USB after it has run through any CPU prescalers. Note that this value
12# does not *change* the processor frequency - it should merely be updated to
13# reflect the processor speed set externally so that the code can use accurate
14# software delays.
15F_CPU = 16000000
16
17
18
19# LUFA specific
20#
21# Target architecture (see library "Board Types" documentation).
22ARCH = AVR8
23
24# Input clock frequency.
25# This will define a symbol, F_USB, in all source code files equal to the
26# input clock frequency (before any prescaling is performed) in Hz. This value may
27# differ from F_CPU if prescaling is used on the latter, and is required as the
28# raw input clock is fed directly to the PLL sections of the AVR for high speed
29# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
30# at the end, this will be done automatically to create a 32-bit value in your
31# source code.
32#
33# If no clock division is performed on the input clock inside the AVR (via the
34# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
35F_USB = $(F_CPU)
36
37# Interrupt driven control endpoint task(+60)
38OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
39
40
41# Boot Section Size in *bytes*
42# Teensy halfKay 512
43# Teensy++ halfKay 1024
44# Atmel DFU loader 4096
45# LUFA bootloader 4096
46# USBaspLoader 2048
47OPT_DEFS += -DBOOTLOADER_SIZE=4096
48
49
50# Build Options
51# comment out to disable the options.
52#
53# BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
54MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
55EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
56CONSOLE_ENABLE = yes # Console for debug(+400)
57COMMAND_ENABLE = yes # Commands for debug and configuration
58NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
59
60# Optimize size but this may cause error "relocation truncated to fit"
61#EXTRALDFLAGS = -Wl,--relax
62
63CUSTOM_MATRIX = yes
64SRC += matrix.c