aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzvecr <git@zvecr.com>2019-02-18 01:47:01 +0000
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-02-17 17:47:01 -0800
commit657d05593491f7d4d1346f0f06f9972fdbde9095 (patch)
tree8a41e8d1e95cc4afe721ce375bd46d46d671f2e5
parent278a6c74f34784dde307d6d024aaea0e783c1f3f (diff)
downloadqmk_firmware-657d05593491f7d4d1346f0f06f9972fdbde9095.tar.gz
qmk_firmware-657d05593491f7d4d1346f0f06f9972fdbde9095.zip
Inital port of xd84 (#5164)
* Inital port of xd84 * Inital port of xd84 - review comments
-rw-r--r--keyboards/xd84/config.h241
-rw-r--r--keyboards/xd84/custom_matrix_helper.c112
-rw-r--r--keyboards/xd84/dev.md132
-rw-r--r--keyboards/xd84/info.json18
-rw-r--r--keyboards/xd84/keymaps/default/keymap.c38
-rw-r--r--keyboards/xd84/keymaps/default_iso/keymap.c38
-rw-r--r--keyboards/xd84/matrix.c94
-rw-r--r--keyboards/xd84/pca9555.c63
-rw-r--r--keyboards/xd84/pca9555.h55
-rw-r--r--keyboards/xd84/readme.md23
-rw-r--r--keyboards/xd84/rules.mk86
-rw-r--r--keyboards/xd84/xd84.c43
-rw-r--r--keyboards/xd84/xd84.h59
13 files changed, 1002 insertions, 0 deletions
diff --git a/keyboards/xd84/config.h b/keyboards/xd84/config.h
new file mode 100644
index 000000000..b2f850c18
--- /dev/null
+++ b/keyboards/xd84/config.h
@@ -0,0 +1,241 @@
1/* Copyright 2019
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#pragma once
18
19#include "config_common.h"
20
21/* USB Device descriptor parameter */
22#define VENDOR_ID 0xFEED
23#define PRODUCT_ID 0x4084
24#define DEVICE_VER 0x0001
25#define MANUFACTURER KPrepublic
26#define PRODUCT XD84
27#define DESCRIPTION KPrepublic XD84
28
29/* key matrix size */
30#define MATRIX_ROWS 6
31#define MATRIX_COLS 15
32
33/*
34 * Keyboard Matrix Assignments
35 *
36 * Change this to how you wired your keyboard
37 * COLS: AVR pins used for columns, left to right
38 * ROWS: AVR pins used for rows, top to bottom
39 * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
40 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
41 *
42*/
43//#define MATRIX_ROW_PINS { D0, D5 }
44//#define MATRIX_COL_PINS { F1, F0, B0 }
45//#define UNUSED_PINS
46
47/* COL2ROW, ROW2COL */
48//#define DIODE_DIRECTION COL2ROW
49
50// TODO: NOT WORKING - original kimera code seems to suggest B6 or C7 in backlight.c
51// however tracing seems to suggest this is not true (as C7 is RGB)
52#define BACKLIGHT_PIN B5
53#define BACKLIGHT_LEVELS 3
54// #define BACKLIGHT_BREATHING
55
56#define RGB_DI_PIN C7
57#define RGBLED_NUM 7
58#define RGBLIGHT_ANIMATIONS
59// #ifdef RGB_DI_PIN
60// #define RGBLIGHT_HUE_STEP 8
61// #define RGBLIGHT_SAT_STEP 8
62// #define RGBLIGHT_VAL_STEP 8
63// #define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */
64// #define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */
65// /*== all animations enable ==*/
66// #define RGBLIGHT_ANIMATIONS
67// /*== or choose animations ==*/
68// #define RGBLIGHT_EFFECT_BREATHING
69// #define RGBLIGHT_EFFECT_RAINBOW_MOOD
70// #define RGBLIGHT_EFFECT_RAINBOW_SWIRL
71// #define RGBLIGHT_EFFECT_SNAKE
72// #define RGBLIGHT_EFFECT_KNIGHT
73// #define RGBLIGHT_EFFECT_CHRISTMAS
74// #define RGBLIGHT_EFFECT_STATIC_GRADIENT
75// #define RGBLIGHT_EFFECT_RGB_TEST
76// #define RGBLIGHT_EFFECT_ALTERNATING
77// #endif
78
79/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
80#define DEBOUNCING_DELAY 5
81
82/* define if matrix has ghost (lacks anti-ghosting diodes) */
83//#define MATRIX_HAS_GHOST
84
85/* number of backlight levels */
86
87/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
88#define LOCKING_SUPPORT_ENABLE
89/* Locking resynchronize hack */
90#define LOCKING_RESYNC_ENABLE
91
92/* If defined, GRAVE_ESC will always act as ESC when CTRL is held.
93 * This is userful for the Windows task manager shortcut (ctrl+shift+esc).
94 */
95// #define GRAVE_ESC_CTRL_OVERRIDE
96
97/*
98 * Force NKRO
99 *
100 * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved
101 * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the
102 * makefile for this to work.)
103 *
104 * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N)
105 * until the next keyboard reset.
106 *
107 * NKRO may prevent your keystrokes from being detected in the BIOS, but it is
108 * fully operational during normal computer usage.
109 *
110 * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N)
111 * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by
112 * bootmagic, NKRO mode will always be enabled until it is toggled again during a
113 * power-up.
114 *
115 */
116//#define FORCE_NKRO
117
118/*
119 * Magic Key Options
120 *
121 * Magic keys are hotkey commands that allow control over firmware functions of
122 * the keyboard. They are best used in combination with the HID Listen program,
123 * found here: https://www.pjrc.com/teensy/hid_listen.html
124 *
125 * The options below allow the magic key functionality to be changed. This is
126 * useful if your keyboard/keypad is missing keys and you want magic key support.
127 *
128 */
129
130/* key combination for magic key command */
131/* defined by default; to change, uncomment and set to the combination you want */
132// #define IS_COMMAND() (get_mods() == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
133
134/* control how magic key switches layers */
135//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true
136//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true
137//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false
138
139/* override magic key keymap */
140//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
141//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
142//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
143//#define MAGIC_KEY_HELP1 H
144//#define MAGIC_KEY_HELP2 SLASH
145//#define MAGIC_KEY_DEBUG D
146//#define MAGIC_KEY_DEBUG_MATRIX X
147//#define MAGIC_KEY_DEBUG_KBD K
148//#define MAGIC_KEY_DEBUG_MOUSE M
149//#define MAGIC_KEY_VERSION V
150//#define MAGIC_KEY_STATUS S
151//#define MAGIC_KEY_CONSOLE C
152//#define MAGIC_KEY_LAYER0_ALT1 ESC
153//#define MAGIC_KEY_LAYER0_ALT2 GRAVE
154//#define MAGIC_KEY_LAYER0 0
155//#define MAGIC_KEY_LAYER1 1
156//#define MAGIC_KEY_LAYER2 2
157//#define MAGIC_KEY_LAYER3 3
158//#define MAGIC_KEY_LAYER4 4
159//#define MAGIC_KEY_LAYER5 5
160//#define MAGIC_KEY_LAYER6 6
161//#define MAGIC_KEY_LAYER7 7
162//#define MAGIC_KEY_LAYER8 8
163//#define MAGIC_KEY_LAYER9 9
164//#define MAGIC_KEY_BOOTLOADER PAUSE
165//#define MAGIC_KEY_LOCK CAPS
166//#define MAGIC_KEY_EEPROM E
167//#define MAGIC_KEY_NKRO N
168//#define MAGIC_KEY_SLEEP_LED Z
169
170/*
171 * Feature disable options
172 * These options are also useful to firmware size reduction.
173 */
174
175/* disable debug print */
176//#define NO_DEBUG
177
178/* disable print */
179//#define NO_PRINT
180
181/* disable action features */
182//#define NO_ACTION_LAYER
183//#define NO_ACTION_TAPPING
184//#define NO_ACTION_ONESHOT
185//#define NO_ACTION_MACRO
186//#define NO_ACTION_FUNCTION
187
188/*
189 * MIDI options
190 */
191
192/* Prevent use of disabled MIDI features in the keymap */
193//#define MIDI_ENABLE_STRICT 1
194
195/* enable basic MIDI features:
196 - MIDI notes can be sent when in Music mode is on
197*/
198//#define MIDI_BASIC
199
200/* enable advanced MIDI features:
201 - MIDI notes can be added to the keymap
202 - Octave shift and transpose
203 - Virtual sustain, portamento, and modulation wheel
204 - etc.
205*/
206//#define MIDI_ADVANCED
207
208/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */
209//#define MIDI_TONE_KEYCODE_OCTAVES 1
210
211/*
212 * HD44780 LCD Display Configuration
213 */
214/*
215#define LCD_LINES 2 //< number of visible lines of the display
216#define LCD_DISP_LENGTH 16 //< visibles characters per line of the display
217
218#define LCD_IO_MODE 1 //< 0: memory mapped mode, 1: IO port mode
219
220#if LCD_IO_MODE
221#define LCD_PORT PORTB //< port for the LCD lines
222#define LCD_DATA0_PORT LCD_PORT //< port for 4bit data bit 0
223#define LCD_DATA1_PORT LCD_PORT //< port for 4bit data bit 1
224#define LCD_DATA2_PORT LCD_PORT //< port for 4bit data bit 2
225#define LCD_DATA3_PORT LCD_PORT //< port for 4bit data bit 3
226#define LCD_DATA0_PIN 4 //< pin for 4bit data bit 0
227#define LCD_DATA1_PIN 5 //< pin for 4bit data bit 1
228#define LCD_DATA2_PIN 6 //< pin for 4bit data bit 2
229#define LCD_DATA3_PIN 7 //< pin for 4bit data bit 3
230#define LCD_RS_PORT LCD_PORT //< port for RS line
231#define LCD_RS_PIN 3 //< pin for RS line
232#define LCD_RW_PORT LCD_PORT //< port for RW line
233#define LCD_RW_PIN 2 //< pin for RW line
234#define LCD_E_PORT LCD_PORT //< port for Enable line
235#define LCD_E_PIN 1 //< pin for Enable line
236#endif
237*/
238
239/* Bootmagic Lite key configuration */
240// #define BOOTMAGIC_LITE_ROW 0
241// #define BOOTMAGIC_LITE_COLUMN 0
diff --git a/keyboards/xd84/custom_matrix_helper.c b/keyboards/xd84/custom_matrix_helper.c
new file mode 100644
index 000000000..a6a0a041d
--- /dev/null
+++ b/keyboards/xd84/custom_matrix_helper.c
@@ -0,0 +1,112 @@
1#include <stdint.h>
2#include <stdbool.h>
3#include "wait.h"
4#include "print.h"
5#include "debug.h"
6#include "util.h"
7#include "matrix.h"
8#include "debounce.h"
9#include "quantum.h"
10
11//_____COMMON__________________________________________________________________
12// user-defined overridable functions
13__attribute__((weak)) void matrix_init_kb(void) { matrix_init_user(); }
14__attribute__((weak)) void matrix_scan_kb(void) { matrix_scan_user(); }
15__attribute__((weak)) void matrix_init_user(void) {}
16__attribute__((weak)) void matrix_scan_user(void) {}
17
18
19//_____COULD BE COMMON_________________________________________________________
20/* matrix state(1:on, 0:off) */
21/*static*/ matrix_row_t raw_matrix[MATRIX_ROWS];
22/*static*/ matrix_row_t matrix[MATRIX_ROWS];
23
24#if (MATRIX_COLS <= 8)
25# define print_matrix_header() print("\nr/c 01234567\n")
26# define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row))
27# define matrix_bitpop(i) bitpop(matrix[i])
28# define ROW_SHIFTER ((uint8_t)1)
29#elif (MATRIX_COLS <= 16)
30# define print_matrix_header() print("\nr/c 0123456789ABCDEF\n")
31# define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row))
32# define matrix_bitpop(i) bitpop16(matrix[i])
33# define ROW_SHIFTER ((uint16_t)1)
34#elif (MATRIX_COLS <= 32)
35# define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n")
36# define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row))
37# define matrix_bitpop(i) bitpop32(matrix[i])
38# define ROW_SHIFTER ((uint32_t)1)
39#endif
40
41__attribute__ ((weak))
42uint8_t matrix_rows(void) {
43 return MATRIX_ROWS;
44}
45
46__attribute__ ((weak))
47uint8_t matrix_cols(void) {
48 return MATRIX_COLS;
49}
50
51__attribute__ ((weak))
52matrix_row_t matrix_get_row(uint8_t row) {
53 return matrix[row];
54}
55
56__attribute__ ((weak))
57uint8_t matrix_key_count(void) {
58 uint8_t count = 0;
59 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
60 count += matrix_bitpop(i);
61 }
62 return count;
63}
64
65__attribute__ ((weak))
66void matrix_print(void) {
67 print_matrix_header();
68
69 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
70 phex(row); print(": ");
71 print_matrix_row(row);
72 print("\n");
73 }
74}
75
76
77//_____CUSTOM MATRIX 'LITE'____________________________________________________
78__attribute__ ((weak))
79void custom_matrix_init(void) {
80}
81
82__attribute__ ((weak))
83bool custom_matrix_scan(matrix_row_t current_matrix[]) {
84 bool changed = true;
85 return changed;
86}
87
88__attribute__ ((weak))
89void matrix_init(void) {
90
91 custom_matrix_init();
92
93 // initialize matrix state: all keys off
94 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
95 raw_matrix[i] = 0;
96 matrix[i] = 0;
97 }
98
99 debounce_init(MATRIX_ROWS);
100
101 matrix_init_quantum();
102}
103
104__attribute__ ((weak))
105uint8_t matrix_scan(void) {
106 bool changed = custom_matrix_scan(raw_matrix);
107
108 debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
109
110 matrix_scan_quantum();
111 return 1;
112}
diff --git a/keyboards/xd84/dev.md b/keyboards/xd84/dev.md
new file mode 100644
index 000000000..453edb366
--- /dev/null
+++ b/keyboards/xd84/dev.md
@@ -0,0 +1,132 @@
1# XD84
2
3Development docs covering the following:
4- Kimera core
5- RGB
6- Backlight
7
8## Kimera core
9![Kimera core](https://gd2.alicdn.com/imgextra/i4/159916802/TB2qsIgdrJkpuFjy1zcXXa5FFXa_!!159916802.jpg)
10
11What little available info that was available for the qmk port
12- atmega32u4 16Mhz
13 - board seems to have a 6Mhz crystal
14- 2x PCA9555 I2C IO expander
15
16Links:
17- [Schematic, BOM, Gerbers](/kairyu/kimera/blob/master/kimera_core)
18- [Original firmware](https://github.com/kairyu/tmk_keyboard_custom/tree/master/keyboard/kimera)
19
20```c
21/*
22Kimera_core_v1.0 Components
23
24 U1 (atmega32u4)
25 ,----------------.
26 TX --| TX0(PD3) RAW |--
27 RX --| RX1(PD2) GND |--
28 --| GND RESET |-- RST
29 --| GND VCC |--
30 SDA --| 2(PD1) (PF4)A3 |--
31 SCL --| 3(PD0) (PF5)A2 |--
32 (INT) --| 4(PD4) (PF6)A1 |--
33 --| 5(PC6) (PF7)A0 |--
34 --| 6(PD7) (PB1)15 |-- SCK
35 LED2 --| 7(PE6) (PB3)14 |-- MISO
36 LED1 --| 8(PB4) (PB2)16 |-- MOSI
37 LED3 --| 9(PB5) (PB6)10 |-- LED4
38 `----------------'
39
40 IC1 (PCA9555) IC2 (PCA9555)
41 ,----------. ,----------.
42 SDA --| SDA P00 |-- P1 SDA --| SDA P00 |-- P17
43 SCL --| SCL P01 |-- P2 SCL --| SCL P01 |-- P18
44 INT --| INT P02 |-- P3 INT --| INT P02 |-- P19
45 | P03 |-- P4 | P03 |-- P20
46 GND --| A0 P04 |-- P5 VCC --| A0 P04 |-- P21
47 SJ1 --| A1 P05 |-- P6 SJ1 --| A1 P05 |-- P22
48 SJ2 --| A2 P06 |-- P7 SJ2 --| A2 P06 |-- P23
49 | P07 |-- P8 | P07 |-- P24
50 | | | |
51 | P10 |-- P9 | P10 |-- P25
52 | P11 |-- P10 | P11 |-- P26
53 | P12 |-- P11 | P12 |-- P27
54 | P13 |-- P12 | P13 |-- P28
55 | P14 |-- P13 | P14 |-- P29
56 | P15 |-- P14 | P15 |-- P30
57 | P16 |-- P15 | P16 |-- P31
58 | P17 |-- P16 | P17 |-- P32
59 `----------' `----------'
60*/
61
62```
63
64### Bootloader
65Default bootloader is `atmel-dfu`.
66Reboot to bootloader via magnetic switch next to icsp header.
67Flash using regular dfu methods.
68
69### XD84 pin mappings
70Taken from [kimera-config.json](https://github.com/kairyu/tkg/blob/master/keyboard/config/kimera-config.json)
71
72 "row_mapping": [ 1, 2, 3, 4, 5, 6 ],
73 "col_mapping": [ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 ],
74
75# RGB
76- PIN C7
77- Number of RGB LED 7
78
79# Backlight
80 TODO - not working
81
82## Assumptions
83### Pin/Port mappings
84- All cols are on the same IC
85- All rows are on the same IC and port
86- Pins mapped sequentially
87- Each port only does row or column not a mixture of both
88 - No need to have complex port config
89 -
90
91| ROW index | Kimera Pin | PCA9555 |
92| ----------|------------|-------------------|
93| 0 | 1 | IC1 Port 0 pin 0 |
94| 1 | 2 | IC1 Port 0 pin 1 |
95| 2 | 3 | IC1 Port 0 pin 2 |
96| 3 | 4 | IC1 Port 0 pin 3 |
97| 4 | 5 | IC1 Port 0 pin 4 |
98| 5 | 6 | IC1 Port 0 pin 5 |
99
100- Safe enough to assume `row_index == pin`
101
102
103| COL index | Kimera Pin | PCA9555 |
104| ----------|------------|-------------------|
105| 0 | 17 | IC2 Port 0 pin 0 |
106| 1 | 18 | IC2 Port 0 pin 1 |
107| 2 | 19 | IC2 Port 0 pin 2 |
108| 3 | 20 | IC2 Port 0 pin 3 |
109| 4 | 21 | IC2 Port 0 pin 4 |
110| 5 | 22 | IC2 Port 0 pin 5 |
111| 6 | 23 | IC2 Port 0 pin 6 |
112| 7 | 24 | IC2 Port 0 pin 7 |
113| 8 | 25 | IC2 Port 1 pin 0 |
114| 9 | 26 | IC2 Port 1 pin 1 |
115| 10 | 27 | IC2 Port 1 pin 2 |
116| 11 | 28 | IC2 Port 1 pin 3 |
117| 12 | 29 | IC2 Port 1 pin 4 |
118| 13 | 30 | IC2 Port 1 pin 5 |
119| 14 | 31 | IC2 Port 1 pin 6 |
120
121- Safe enough to assume here col_index does not need to be converted to pin
122- Reading both ports one after the other gives us the same sequential behavior
123 - maps to the usual practice of reading matrix columns
124 - while this technically gives 16 column reads, the 16th column can never be set so is safely ignored
125
126## Notes
127[pca9555 datasheet](https://www.ti.com/lit/ds/symlink/pca9555.pdf)
128
129- Other Kimera based boards with non sequential pin mappings, pins mapped across ICs, or mixed row/col configs will need more complicated `pin -> i2c_addr,port,pin` logic as well as rather more complex pin functions.
130
131## Return to stock firmware
132Not tested but original firmware seems to be available in the [kairyu/tkg-firmware](https://github.com/kairyu/tkg-firmware/blob/master/kimera-core.hex) repo.
diff --git a/keyboards/xd84/info.json b/keyboards/xd84/info.json
new file mode 100644
index 000000000..b701db1b7
--- /dev/null
+++ b/keyboards/xd84/info.json
@@ -0,0 +1,18 @@
1{
2 "keyboard_name": "XD84",
3 "url": "",
4 "maintainer": "qmk",
5 "width": 16,
6 "height": 6,
7 "layouts": {
8 "LAYOUT_75_ansi": {
9 "key_count": 84,
10 "layout": [{"label":"Esc", "x":0, "y":0}, {"label":"F1", "x":1, "y":0}, {"label":"F2", "x":2, "y":0}, {"label":"F3", "x":3, "y":0}, {"label":"F4", "x":4, "y":0}, {"label":"F5", "x":5, "y":0}, {"label":"F6", "x":6, "y":0}, {"label":"F7", "x":7, "y":0}, {"label":"F8", "x":8, "y":0}, {"label":"F9", "x":9, "y":0}, {"label":"F10", "x":10, "y":0}, {"label":"F11", "x":11, "y":0}, {"label":"F12", "x":12, "y":0}, {"label":"PrtSc", "x":13, "y":0}, {"label":"Pause", "x":14, "y":0}, {"label":"Delete", "x":15, "y":0}, {"label":"~", "x":0, "y":1}, {"label":"1", "x":1, "y":1}, {"label":"2", "x":2, "y":1}, {"label":"3", "x":3, "y":1}, {"label":"4", "x":4, "y":1}, {"label":"5", "x":5, "y":1}, {"label":"6", "x":6, "y":1}, {"label":"7", "x":7, "y":1}, {"label":"8", "x":8, "y":1}, {"label":"9", "x":9, "y":1}, {"label":"0", "x":10, "y":1}, {"label":"_", "x":11, "y":1}, {"label":"+", "x":12, "y":1}, {"label":"delete", "x":13, "y":1, "w":2}, {"label":"Home", "x":15, "y":1}, {"label":"Tab", "x":0, "y":2, "w":1.5}, {"label":"Q", "x":1.5, "y":2}, {"label":"W", "x":2.5, "y":2}, {"label":"E", "x":3.5, "y":2}, {"label":"R", "x":4.5, "y":2}, {"label":"T", "x":5.5, "y":2}, {"label":"Y", "x":6.5, "y":2}, {"label":"U", "x":7.5, "y":2}, {"label":"I", "x":8.5, "y":2}, {"label":"O", "x":9.5, "y":2}, {"label":"P", "x":10.5, "y":2}, {"label":"{", "x":11.5, "y":2}, {"label":"}", "x":12.5, "y":2}, {"label":"|", "x":13.5, "y":2, "w":1.5}, {"label":"Page Up", "x":15, "y":2}, {"label":"Caps Lock", "x":0, "y":3, "w":1.75}, {"label":"A", "x":1.75, "y":3}, {"label":"S", "x":2.75, "y":3}, {"label":"D", "x":3.75, "y":3}, {"label":"F", "x":4.75, "y":3}, {"label":"G", "x":5.75, "y":3}, {"label":"H", "x":6.75, "y":3}, {"label":"J", "x":7.75, "y":3}, {"label":"K", "x":8.75, "y":3}, {"label":"L", "x":9.75, "y":3}, {"label":":", "x":10.75, "y":3}, {"label":"\"", "x":11.75, "y":3}, {"label":"Enter", "x":12.75, "y":3, "w":2.25}, {"label":"Page Down", "x":15, "y":3}, {"label":"Shift", "x":0, "y":4, "w":2.25}, {"label":"Z", "x":2.25, "y":4}, {"label":"X", "x":3.25, "y":4}, {"label":"C", "x":4.25, "y":4}, {"label":"V", "x":5.25, "y":4}, {"label":"B", "x":6.25, "y":4}, {"label":"N", "x":7.25, "y":4}, {"label":"M", "x":8.25, "y":4}, {"label":"<", "x":9.25, "y":4}, {"label":">", "x":10.25, "y":4}, {"label":"?", "x":11.25, "y":4}, {"label":"Shift", "x":12.25, "y":4, "w":1.75}, {"label":"\u2191", "x":14, "y":4}, {"label":"End", "x":15, "y":4}, {"label":"Ctrl", "x":0, "y":5, "w":1.25}, {"label":"Win", "x":1.25, "y":5, "w":1.25}, {"label":"Alt", "x":2.5, "y":5, "w":1.25}, {"x":3.75, "y":5, "w":6.25}, {"label":"Alt", "x":10, "y":5}, {"label":"Fn", "x":11, "y":5}, {"label":"Ctrl", "x":12, "y":5}, {"label":"\u2190", "x":13, "y":5}, {"label":"\u2193", "x":14, "y":5}, {"label":"\u2192", "x":15, "y":5}]
11 },
12
13 "LAYOUT_75_iso": {
14 "key_count": 85,
15 "layout": [{"label":"Esc", "x":0, "y":0}, {"label":"F1", "x":1, "y":0}, {"label":"F2", "x":2, "y":0}, {"label":"F3", "x":3, "y":0}, {"label":"F4", "x":4, "y":0}, {"label":"F5", "x":5, "y":0}, {"label":"F6", "x":6, "y":0}, {"label":"F7", "x":7, "y":0}, {"label":"F8", "x":8, "y":0}, {"label":"F9", "x":9, "y":0}, {"label":"F10", "x":10, "y":0}, {"label":"F11", "x":11, "y":0}, {"label":"F12", "x":12, "y":0}, {"label":"PrtSc", "x":13, "y":0}, {"label":"Pause", "x":14, "y":0}, {"label":"Delete", "x":15, "y":0}, {"label":"~", "x":0, "y":1}, {"label":"1", "x":1, "y":1}, {"label":"2", "x":2, "y":1}, {"label":"3", "x":3, "y":1}, {"label":"4", "x":4, "y":1}, {"label":"5", "x":5, "y":1}, {"label":"6", "x":6, "y":1}, {"label":"7", "x":7, "y":1}, {"label":"8", "x":8, "y":1}, {"label":"9", "x":9, "y":1}, {"label":"0", "x":10, "y":1}, {"label":"_", "x":11, "y":1}, {"label":"+", "x":12, "y":1}, {"label":"delete", "x":13, "y":1, "w":2}, {"label":"Home", "x":15, "y":1}, {"label":"Tab", "x":0, "y":2, "w":1.5}, {"label":"Q", "x":1.5, "y":2}, {"label":"W", "x":2.5, "y":2}, {"label":"E", "x":3.5, "y":2}, {"label":"R", "x":4.5, "y":2}, {"label":"T", "x":5.5, "y":2}, {"label":"Y", "x":6.5, "y":2}, {"label":"U", "x":7.5, "y":2}, {"label":"I", "x":8.5, "y":2}, {"label":"O", "x":9.5, "y":2}, {"label":"P", "x":10.5, "y":2}, {"label":"{", "x":11.5, "y":2}, {"label":"}", "x":12.5, "y":2}, {"label":"Enter", "x":13.75, "y":2, "w":1.25, "h":2}, {"label":"Page Up", "x":15, "y":2}, {"label":"Caps Lock", "x":0, "y":3, "w":1.75}, {"label":"A", "x":1.75, "y":3}, {"label":"S", "x":2.75, "y":3}, {"label":"D", "x":3.75, "y":3}, {"label":"F", "x":4.75, "y":3}, {"label":"G", "x":5.75, "y":3}, {"label":"H", "x":6.75, "y":3}, {"label":"J", "x":7.75, "y":3}, {"label":"K", "x":8.75, "y":3}, {"label":"L", "x":9.75, "y":3}, {"label":":", "x":10.75, "y":3}, {"label":"@", "x":11.75, "y":3}, {"label":"~", "x":12.75, "y":3}, {"label":"Page Down", "x":15, "y":3}, {"label":"Shift", "x":0, "y":4, "w":1.25}, {"x":1.25, "y":4}, {"label":"Z", "x":2.25, "y":4}, {"label":"X", "x":3.25, "y":4}, {"label":"C", "x":4.25, "y":4}, {"label":"V", "x":5.25, "y":4}, {"label":"B", "x":6.25, "y":4}, {"label":"N", "x":7.25, "y":4}, {"label":"M", "x":8.25, "y":4}, {"label":"<", "x":9.25, "y":4}, {"label":">", "x":10.25, "y":4}, {"label":"?", "x":11.25, "y":4}, {"label":"Shift", "x":12.25, "y":4, "w":1.75}, {"label":"\u2191", "x":14, "y":4}, {"label":"End", "x":15, "y":4}, {"label":"Ctrl", "x":0, "y":5, "w":1.25}, {"label":"Win", "x":1.25, "y":5, "w":1.25}, {"label":"Alt", "x":2.5, "y":5, "w":1.25}, {"x":3.75, "y":5, "w":6.25}, {"label":"Alt", "x":10, "y":5}, {"label":"Fn", "x":11, "y":5}, {"label":"Ctrl", "x":12, "y":5}, {"label":"\u2190", "x":13, "y":5}, {"label":"\u2193", "x":14, "y":5}, {"label":"\u2192", "x":15, "y":5}]
16 }
17 }
18} \ No newline at end of file
diff --git a/keyboards/xd84/keymaps/default/keymap.c b/keyboards/xd84/keymaps/default/keymap.c
new file mode 100644
index 000000000..4b9cf9fd2
--- /dev/null
+++ b/keyboards/xd84/keymaps/default/keymap.c
@@ -0,0 +1,38 @@
1#include QMK_KEYBOARD_H
2
3#define L1_RGUI LM(1, MOD_RGUI)
4
5const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
6
7 [0] = LAYOUT_75_ansi(
8/* ┌─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┐ */
9 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_F13, KC_PAUS, KC_DEL,
10/* ├─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┴─────────┼─────────┤ */
11 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_HOME,
12/* ├─────────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬──────────────┼─────────┤ */
13 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_PGUP,
14/* ├──────────────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──────────────├─────────┤ */
15 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_PGDN,
16/* ├─────────────────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───────────┬─────────┼─────────┤ */
17 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_END,
18/* ├───────────┬─────────┴─┬───────┴───┬─────┴─────────┴─────────┴─────────┴─────────┴─────────┴───────┬─┴───────┬─┴───────┬─┴───────┬─────────┼─────────┼─────────┤ */
19 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, L1_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
20/* └───────────┴───────────┴───────────┴───────────────────────────────────────────────────────────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┘ */
21 ),
22
23 [1] = LAYOUT_75_ansi(
24/* ┌─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┐ */
25 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
26/* ├─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┴─────────┼─────────┤ */
27 _______, RGB_TOG, RGB_MOD, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
28/* ├─────────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬──────────────┼─────────┤ */
29 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
30/* ├──────────────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──────────────├─────────┤ */
31 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
32/* ├─────────────────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───────────┬─────────┼─────────┤ */
33 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
34/* ├───────────┬─────────┴─┬───────┴───┬─────┴─────────┴─────────┴─────────┴─────────┴─────────┴───────┬─┴───────┬─┴───────┬─┴───────┬─────────┼─────────┼─────────┤ */
35 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
36/* └───────────┴───────────┴───────────┴───────────────────────────────────────────────────────────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┘ */
37 )
38};
diff --git a/keyboards/xd84/keymaps/default_iso/keymap.c b/keyboards/xd84/keymaps/default_iso/keymap.c
new file mode 100644
index 000000000..18a0f06a8
--- /dev/null
+++ b/keyboards/xd84/keymaps/default_iso/keymap.c
@@ -0,0 +1,38 @@
1#include QMK_KEYBOARD_H
2
3#define L1_RGUI LM(1, MOD_RGUI)
4
5const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
6
7 [0] = LAYOUT_75_iso(
8/* ┌─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┐ */
9 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_PSCR, KC_PAUS, KC_DEL,
10/* ├─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┴─────────┼─────────┤ */
11 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_HOME,
12/* ├─────────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬──────────────┼─────────┤ */
13 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_PGUP,
14/* ├──────────────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬ ├─────────┤ */
15 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_NUHS, KC_ENT, KC_PGDN,
16/* ├───────────┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴─────────┴─┬─────────┼─────────┤ */
17 KC_LSFT, KC_NUBS, 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_END,
18/* ├───────────┼─────────┴─┬───────┴───┬─────┴─────────┴─────────┴─────────┴─────────┴─────────┴───────┬─┴───────┬─┴───────┬─┴───────┬─────────┼─────────┼─────────┤ */
19 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, L1_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
20/* └───────────┴───────────┴───────────┴───────────────────────────────────────────────────────────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┘ */
21 ),
22
23 [1] = LAYOUT_75_iso(
24/* ┌─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┐ */
25 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
26/* ├─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┴─────────┼─────────┤ */
27 _______, RGB_TOG, RGB_MOD, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
28/* ├─────────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬──────────────┼─────────┤ */
29 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
30/* ├──────────────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬──────┴──┬ ├─────────┤ */
31 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
32/* ├───────────┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴─────────┴─┬─────────┼─────────┤ */
33 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
34/* ├───────────┼─────────┴─┬───────┴───┬─────┴─────────┴─────────┴─────────┴─────────┴─────────┴───────┬─┴───────┬─┴───────┬─┴───────┬─────────┼─────────┼─────────┤ */
35 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
36/* └───────────┴───────────┴───────────┴───────────────────────────────────────────────────────────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┘ */
37 )
38};
diff --git a/keyboards/xd84/matrix.c b/keyboards/xd84/matrix.c
new file mode 100644
index 000000000..a35905047
--- /dev/null
+++ b/keyboards/xd84/matrix.c
@@ -0,0 +1,94 @@
1/* Copyright 2019
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#include <stdint.h>
17#include <stdbool.h>
18#include <avr/io.h>
19#include <string.h>
20#include "matrix.h"
21#include "pca9555.h"
22#include "quantum.h"
23
24#include "debug.h"
25
26// PCA9555 slave addresses
27#define IC1 0x20
28#define IC2 0x21
29
30//_____Utility funcs___________________________________________________________
31
32static void init_pins(void) {
33 // init all cols high - IC2 all input
34 pca9555_set_config(IC2, PCA9555_PORT0, ALL_INPUT);//same as initial state
35 pca9555_set_config(IC2, PCA9555_PORT1, ALL_INPUT);//same as initial state
36
37 // init all rows - IC1 port0 input
38 pca9555_set_config(IC1, PCA9555_PORT0, ALL_INPUT);//same as initial state
39}
40
41static void select_row(uint8_t row) {
42 // For the XD84 all rows are on the same IC and port
43 // so its safe enough to assume here row == pin
44 uint8_t pin = row;
45 uint8_t mask = 1 << pin;
46
47 pca9555_set_output(IC1, PCA9555_PORT0, ALL_HIGH & (~mask));
48 pca9555_set_config(IC1, PCA9555_PORT0, ALL_INPUT & (~mask));
49}
50
51static uint16_t read_cols(void) {
52 uint16_t state_1 = pca9555_readPins(IC2, PCA9555_PORT0);
53 uint16_t state_2 = pca9555_readPins(IC2, PCA9555_PORT1);
54
55 // For the XD84 all cols are on the same IC and mapped sequentially
56 // while this technically gives 16 column reads,
57 // the 16th column can never be set so is safely ignored
58 return ~((state_2 << 8) | state_1);
59}
60
61static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) {
62 // Store last value of row prior to reading
63 matrix_row_t last_row_value = current_matrix[current_row];
64
65 // Clear data in matrix row
66 current_matrix[current_row] = 0;
67
68 // Select row and wait for row selecton to stabilize
69 select_row(current_row);
70 wait_us(30);
71
72 current_matrix[current_row] = read_cols();
73
74 // No need to Unselect row as the next `select_row` will blank everything
75
76 return (last_row_value != current_matrix[current_row]);
77}
78
79//_____CUSTOM MATRIX IMPLEMENTATION____________________________________________________
80
81void custom_matrix_init(void) {
82 pca9555_init(IC1);
83 pca9555_init(IC2);
84
85 init_pins();
86}
87
88bool custom_matrix_scan(matrix_row_t current_matrix[]) {
89 bool changed = false;
90 for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
91 changed |= read_cols_on_row(current_matrix, current_row);
92 }
93 return changed;
94} \ No newline at end of file
diff --git a/keyboards/xd84/pca9555.c b/keyboards/xd84/pca9555.c
new file mode 100644
index 000000000..df4631e9d
--- /dev/null
+++ b/keyboards/xd84/pca9555.c
@@ -0,0 +1,63 @@
1#include "i2c_master.h"
2#include "pca9555.h"
3
4#include "debug.h"
5
6#define SLAVE_TO_ADDR(n) (n<<1)
7#define TIMEOUT 100
8
9enum {
10 CMD_INPUT_0 = 0,
11 CMD_INPUT_1,
12 CMD_OUTPUT_0,
13 CMD_OUTPUT_1,
14 CMD_INVERSION_0,
15 CMD_INVERSION_1,
16 CMD_CONFIG_0,
17 CMD_CONFIG_1
18};
19
20void pca9555_init(uint8_t slave_addr) {
21 static uint8_t s_init = 0;
22 if (!s_init) {
23 i2c_init();
24
25 s_init=1;
26 }
27
28 // TODO: could check device connected
29 //i2c_start(SLAVE_TO_ADDR(slave) | I2C_WRITE);
30 //i2c_stop();
31}
32
33void pca9555_set_config(uint8_t slave_addr, uint8_t port, uint8_t conf) {
34 uint8_t addr = SLAVE_TO_ADDR(slave_addr);
35 uint8_t cmd = port ? CMD_OUTPUT_1 : CMD_OUTPUT_0;
36
37 i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
38 if (ret != I2C_STATUS_SUCCESS) {
39 print("pca9555_set_config::FAILED\n");
40 }
41}
42
43void pca9555_set_output(uint8_t slave_addr, uint8_t port, uint8_t conf) {
44 uint8_t addr = SLAVE_TO_ADDR(slave_addr);
45 uint8_t cmd = port ? CMD_CONFIG_1 : CMD_CONFIG_0;
46
47 i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
48 if (ret != I2C_STATUS_SUCCESS) {
49 print("pca9555_set_output::FAILED\n");
50 }
51}
52
53uint8_t pca9555_readPins(uint8_t slave_addr, uint8_t port) {
54 uint8_t addr = SLAVE_TO_ADDR(slave_addr);
55 uint8_t cmd = port ? CMD_INPUT_1 : CMD_INPUT_0;
56
57 uint8_t data = 0;
58 i2c_status_t ret = i2c_readReg(addr, cmd, &data, sizeof(data), TIMEOUT);
59 if (ret != I2C_STATUS_SUCCESS) {
60 print("pca9555_readPins::FAILED\n");
61 }
62 return data;
63}
diff --git a/keyboards/xd84/pca9555.h b/keyboards/xd84/pca9555.h
new file mode 100644
index 000000000..6aaee8a6f
--- /dev/null
+++ b/keyboards/xd84/pca9555.h
@@ -0,0 +1,55 @@
1/* Copyright 2019
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#pragma once
17
18/*
19 PCA9555
20 ,----------.
21 SDA --| SDA P00 |-- P1
22 SCL --| SCL P01 |-- P2
23 INT --| INT P02 |-- P3
24 | P03 |-- P4
25 A0 --| A0 P04 |-- P5
26 A1 --| A1 P05 |-- P6
27 A2 --| A2 P06 |-- P7
28 | P07 |-- P8
29 | |
30 | P10 |-- P10
31 | P11 |-- P11
32 | P12 |-- P12
33 | P13 |-- P13
34 | P14 |-- P14
35 | P15 |-- P15
36 | P16 |-- P16
37 | P17 |-- P17
38 `----------'
39*/
40
41#define PCA9555_PORT0 0
42#define PCA9555_PORT1 1
43
44#define ALL_OUTPUT 0
45#define ALL_INPUT 0xFF
46#define ALL_LOW 0
47#define ALL_HIGH 0xFF
48
49void pca9555_init(uint8_t slave_addr);
50
51void pca9555_set_config(uint8_t slave_addr, uint8_t port, uint8_t conf);
52
53void pca9555_set_output(uint8_t slave_addr, uint8_t port, uint8_t conf);
54
55uint8_t pca9555_readPins(uint8_t slave_addr, uint8_t port); \ No newline at end of file
diff --git a/keyboards/xd84/readme.md b/keyboards/xd84/readme.md
new file mode 100644
index 000000000..38b4efcba
--- /dev/null
+++ b/keyboards/xd84/readme.md
@@ -0,0 +1,23 @@
1# XD84
2
3![XD84](https://cdn.shopify.com/s/files/1/2711/4238/products/HTB17eeJSXXXXXbIXFXXq6xXFXXXp_1024x1024.jpg?v=1515505994)
4
5Compact With 84 Keys & RGB LED Underglow
6- Designed by Xiudi
7- Up to 87 keys
8 - iso and ansi support
9- Uses Kimera core
10
11Keyboard Maintainer: QMK Community
12Hardware Supported: XD84
13Hardware Availability: [KPrepublic](https://kprepublic.com/products/xd84-xiudi-70-custom-keyboard-pcb)
14
15Make example for this keyboard (after setting up your build environment):
16
17 make xd84:default
18
19Install examples:
20
21 make xd84:default:dfu
22
23See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
diff --git a/keyboards/xd84/rules.mk b/keyboards/xd84/rules.mk
new file mode 100644
index 000000000..0806d092f
--- /dev/null
+++ b/keyboards/xd84/rules.mk
@@ -0,0 +1,86 @@
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# Bootloader selection
42# Teensy halfkay
43# Pro Micro caterina
44# Atmel DFU atmel-dfu
45# LUFA DFU lufa-dfu
46# QMK DFU qmk-dfu
47# atmega32a bootloadHID
48BOOTLOADER = atmel-dfu
49
50
51# If you don't know the bootloader type, then you can specify the
52# Boot Section Size in *bytes* by uncommenting out the OPT_DEFS line
53# Teensy halfKay 512
54# Teensy++ halfKay 1024
55# Atmel DFU loader 4096
56# LUFA bootloader 4096
57# USBaspLoader 2048
58# OPT_DEFS += -DBOOTLOADER_SIZE=4096
59
60
61# Build Options
62# change yes to no to disable
63#
64BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration(+1000)
65MOUSEKEY_ENABLE = no # Mouse keys(+4700)
66EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
67CONSOLE_ENABLE = no # Console for debug(+400)
68COMMAND_ENABLE = no # Commands for debug and configuration
69# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
70SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
71# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
72NKRO_ENABLE = no # USB Nkey Rollover
73BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality on B7 by default
74RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
75MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config)
76UNICODE_ENABLE = no # Unicode
77BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
78AUDIO_ENABLE = no # Audio output on port C6
79FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
80HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400)
81
82# custom matrix setup
83CUSTOM_MATRIX = yes
84SRC = i2c_master.c custom_matrix_helper.c pca9555.c matrix.c
85
86LAYOUTS = 75_ansi 75_iso \ No newline at end of file
diff --git a/keyboards/xd84/xd84.c b/keyboards/xd84/xd84.c
new file mode 100644
index 000000000..f7048f325
--- /dev/null
+++ b/keyboards/xd84/xd84.c
@@ -0,0 +1,43 @@
1/* Copyright 2019
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#include "xd84.h"
17
18void matrix_init_kb(void) {
19 // put your keyboard start-up code here
20 // runs once when the firmware starts up
21
22 matrix_init_user();
23}
24
25void matrix_scan_kb(void) {
26 // put your looping keyboard code here
27 // runs every cycle (a lot)
28
29 matrix_scan_user();
30}
31
32bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
33 // put your per-action keyboard code here
34 // runs for every action, just before processing by the firmware
35
36 return process_record_user(keycode, record);
37}
38
39void led_set_kb(uint8_t usb_led) {
40 // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
41
42 led_set_user(usb_led);
43}
diff --git a/keyboards/xd84/xd84.h b/keyboards/xd84/xd84.h
new file mode 100644
index 000000000..d59956f69
--- /dev/null
+++ b/keyboards/xd84/xd84.h
@@ -0,0 +1,59 @@
1/* Copyright 2019
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#pragma once
17
18#include "quantum.h"
19#define ____ KC_NO
20
21/* This a shortcut to help you visually see your layout.
22 *
23 * The first section contains all of the arguments representing the physical
24 * layout of the board and position of the keys.
25 *
26 * The second converts the arguments into a two-dimensional array which
27 * represents the switch matrix.
28 */
29#define LAYOUT_75_ansi( \
30 K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K113, K114, K115, K116, \
31 K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, K212, K213, K214, K216, \
32 K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311, K312, K313, K314, K316, \
33 K401, K402, K403, K404, K405, K406, K407, K408, K409, K410, K411, K412, K414, K416, \
34 K501, K503, K504, K505, K506, K507, K508, K509, K510, K511, K512, K513, K515, K516, \
35 K601, K602, K603, K607, K611, K612, K613, K614, K615, K616 \
36) { \
37 { K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K113, K114, K116 }, \
38 { K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, K212, K213, K214, K216 }, \
39 { K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311, K312, K313, K314, K316 }, \
40 { K401, K402, K403, K404, K405, K406, K407, K408, K409, K410, K411, K412, ____, K414, K416 }, \
41 { K501, ____, K503, K504, K505, K506, K507, K508, K509, K510, K511, K512, K513, K515, K516 }, \
42 { K601, K602, K603, ____, ____, K607, K115, ____, K613, ____, K611, K612, K614, K615, K616 } \
43}
44
45#define LAYOUT_75_iso( \
46 K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K113, K114, K115, K116, \
47 K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, K212, K213, K214, K216, \
48 K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311, K312, K313, K316, \
49 K401, K402, K403, K404, K405, K406, K407, K408, K409, K410, K411, K412, K414, K415, K416, \
50 K501, K502, K503, K504, K505, K506, K507, K508, K509, K510, K511, K512, K513, K515, K516, \
51 K601, K602, K603, K607, K611, K612, K613, K614, K615, K616 \
52) { \
53 { K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, K112, K113, K114, K116 }, \
54 { K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, K212, K213, K214, K216 }, \
55 { K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311, K312, K313, ____, K316 }, \
56 { K401, K402, K403, K404, K405, K406, K407, K408, K409, K410, K411, K412, K414, K415, K416 }, \
57 { K501, K502, K503, K504, K505, K506, K507, K508, K509, K510, K511, K512, K513, K515, K516 }, \
58 { K601, K602, K603, ____, ____, K607, K115, ____, K613, ____, K611, K612, K614, K615, K616 } \
59}