diff options
Diffstat (limited to 'keyboards/dc01/left')
-rw-r--r-- | keyboards/dc01/left/config.h | 124 | ||||
-rw-r--r-- | keyboards/dc01/left/i2c.c | 159 | ||||
-rw-r--r-- | keyboards/dc01/left/i2c.h | 28 | ||||
-rw-r--r-- | keyboards/dc01/left/info.json | 13 | ||||
-rw-r--r-- | keyboards/dc01/left/keymaps/default/keymap.c | 25 | ||||
-rw-r--r-- | keyboards/dc01/left/keymaps/default/readme.md | 9 | ||||
-rw-r--r-- | keyboards/dc01/left/keymaps/via/keymap.c | 46 | ||||
-rw-r--r-- | keyboards/dc01/left/keymaps/via/readme.md | 11 | ||||
-rwxr-xr-x | keyboards/dc01/left/keymaps/via/rules.mk | 1 | ||||
-rw-r--r-- | keyboards/dc01/left/left.c | 16 | ||||
-rw-r--r-- | keyboards/dc01/left/left.h | 48 | ||||
-rw-r--r-- | keyboards/dc01/left/matrix.c | 455 | ||||
-rw-r--r-- | keyboards/dc01/left/readme.md | 15 | ||||
-rw-r--r-- | keyboards/dc01/left/rules.mk | 21 |
14 files changed, 971 insertions, 0 deletions
diff --git a/keyboards/dc01/left/config.h b/keyboards/dc01/left/config.h new file mode 100644 index 000000000..bc934e4a3 --- /dev/null +++ b/keyboards/dc01/left/config.h | |||
@@ -0,0 +1,124 @@ | |||
1 | /* | ||
2 | Copyright 2018 Yiancar | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation, either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #pragma once | ||
19 | |||
20 | #include "config_common.h" | ||
21 | |||
22 | /* USB Device descriptor parameter */ | ||
23 | #define VENDOR_ID 0x8968 | ||
24 | #define PRODUCT_ID 0x1010 | ||
25 | #define DEVICE_VER 0x0001 | ||
26 | #define MANUFACTURER Mechboards | ||
27 | #define PRODUCT DC01 Left | ||
28 | |||
29 | /* key matrix size */ | ||
30 | #define MATRIX_ROWS 5 | ||
31 | #define MATRIX_COLS 21 | ||
32 | #define MATRIX_COLS_SCANNED 6 | ||
33 | |||
34 | /* | ||
35 | * Keyboard Matrix Assignments | ||
36 | * | ||
37 | * Change this to how you wired your keyboard | ||
38 | * COLS: AVR pins used for columns, left to right | ||
39 | * ROWS: AVR pins used for rows, top to bottom | ||
40 | * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) | ||
41 | * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) | ||
42 | * | ||
43 | */ | ||
44 | #define MATRIX_ROW_PINS { B6, B5, B4, D7, D6 } | ||
45 | #define MATRIX_COL_PINS { F4, F1, F0, F7, F6, F5, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN, NO_PIN } | ||
46 | #define UNUSED_PINS | ||
47 | |||
48 | #define F_SCL 350000UL | ||
49 | |||
50 | /* COL2ROW, ROW2COL*/ | ||
51 | #define DIODE_DIRECTION COL2ROW | ||
52 | |||
53 | // #define BACKLIGHT_PIN B7 | ||
54 | // #define BACKLIGHT_BREATHING | ||
55 | // #define BACKLIGHT_LEVELS 3 | ||
56 | |||
57 | /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ | ||
58 | #define DEBOUNCE 5 | ||
59 | |||
60 | /* define if matrix has ghost (lacks anti-ghosting diodes) */ | ||
61 | //#define MATRIX_HAS_GHOST | ||
62 | |||
63 | /* number of backlight levels */ | ||
64 | |||
65 | /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ | ||
66 | #define LOCKING_SUPPORT_ENABLE | ||
67 | /* Locking resynchronize hack */ | ||
68 | #define LOCKING_RESYNC_ENABLE | ||
69 | |||
70 | /* If defined, GRAVE_ESC will always act as ESC when CTRL is held. | ||
71 | * This is userful for the Windows task manager shortcut (ctrl+shift+esc). | ||
72 | */ | ||
73 | // #define GRAVE_ESC_CTRL_OVERRIDE | ||
74 | |||
75 | /* | ||
76 | * Force NKRO | ||
77 | * | ||
78 | * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved | ||
79 | * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the | ||
80 | * makefile for this to work.) | ||
81 | * | ||
82 | * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) | ||
83 | * until the next keyboard reset. | ||
84 | * | ||
85 | * NKRO may prevent your keystrokes from being detected in the BIOS, but it is | ||
86 | * fully operational during normal computer usage. | ||
87 | * | ||
88 | * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) | ||
89 | * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by | ||
90 | * bootmagic, NKRO mode will always be enabled until it is toggled again during a | ||
91 | * power-up. | ||
92 | * | ||
93 | */ | ||
94 | //#define FORCE_NKRO | ||
95 | |||
96 | /* | ||
97 | * Magic Key Options | ||
98 | * | ||
99 | * Magic keys are hotkey commands that allow control over firmware functions of | ||
100 | * the keyboard. They are best used in combination with the HID Listen program, | ||
101 | * found here: https://www.pjrc.com/teensy/hid_listen.html | ||
102 | * | ||
103 | * The options below allow the magic key functionality to be changed. This is | ||
104 | * useful if your keyboard/keypad is missing keys and you want magic key support. | ||
105 | * | ||
106 | */ | ||
107 | |||
108 | /* | ||
109 | * Feature disable options | ||
110 | * These options are also useful to firmware size reduction. | ||
111 | */ | ||
112 | |||
113 | /* disable debug print */ | ||
114 | //#define NO_DEBUG | ||
115 | |||
116 | /* disable print */ | ||
117 | //#define NO_PRINT | ||
118 | |||
119 | /* disable action features */ | ||
120 | //#define NO_ACTION_LAYER | ||
121 | //#define NO_ACTION_TAPPING | ||
122 | //#define NO_ACTION_ONESHOT | ||
123 | //#define NO_ACTION_MACRO | ||
124 | //#define NO_ACTION_FUNCTION | ||
diff --git a/keyboards/dc01/left/i2c.c b/keyboards/dc01/left/i2c.c new file mode 100644 index 000000000..c72789403 --- /dev/null +++ b/keyboards/dc01/left/i2c.c | |||
@@ -0,0 +1,159 @@ | |||
1 | #include <util/twi.h> | ||
2 | #include <avr/io.h> | ||
3 | #include <stdlib.h> | ||
4 | #include <avr/interrupt.h> | ||
5 | #include <util/twi.h> | ||
6 | #include <stdbool.h> | ||
7 | #include "i2c.h" | ||
8 | |||
9 | // Limits the amount of we wait for any one i2c transaction. | ||
10 | // Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is | ||
11 | // 9 bits, a single transaction will take around 90μs to complete. | ||
12 | // | ||
13 | // (F_CPU/SCL_CLOCK) => # of μC cycles to transfer a bit | ||
14 | // poll loop takes at least 8 clock cycles to execute | ||
15 | #define I2C_LOOP_TIMEOUT (9+1)*(F_CPU/SCL_CLOCK)/8 | ||
16 | |||
17 | #define BUFFER_POS_INC() (slave_buffer_pos = (slave_buffer_pos+1)%SLAVE_BUFFER_SIZE) | ||
18 | |||
19 | volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; | ||
20 | |||
21 | static volatile uint8_t slave_buffer_pos; | ||
22 | static volatile bool slave_has_register_set = false; | ||
23 | |||
24 | // Wait for an i2c operation to finish | ||
25 | inline static | ||
26 | void i2c_delay(void) { | ||
27 | uint16_t lim = 0; | ||
28 | while(!(TWCR & (1<<TWINT)) && lim < I2C_LOOP_TIMEOUT) | ||
29 | lim++; | ||
30 | |||
31 | // easier way, but will wait slightly longer | ||
32 | // _delay_us(100); | ||
33 | } | ||
34 | |||
35 | // Setup twi to run at 100kHz | ||
36 | void i2c_master_init(void) { | ||
37 | // no prescaler | ||
38 | TWSR = 0; | ||
39 | // Set TWI clock frequency to SCL_CLOCK. Need TWBR>10. | ||
40 | // Check datasheets for more info. | ||
41 | TWBR = ((F_CPU/SCL_CLOCK)-16)/2; | ||
42 | } | ||
43 | |||
44 | // Start a transaction with the given i2c slave address. The direction of the | ||
45 | // transfer is set with I2C_READ and I2C_WRITE. | ||
46 | // returns: 0 => success | ||
47 | // 1 => error | ||
48 | uint8_t i2c_master_start(uint8_t address) { | ||
49 | TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTA); | ||
50 | |||
51 | i2c_delay(); | ||
52 | |||
53 | // check that we started successfully | ||
54 | if ( (TW_STATUS != TW_START) && (TW_STATUS != TW_REP_START)) | ||
55 | return 1; | ||
56 | |||
57 | TWDR = address; | ||
58 | TWCR = (1<<TWINT) | (1<<TWEN); | ||
59 | |||
60 | i2c_delay(); | ||
61 | |||
62 | if ( (TW_STATUS != TW_MT_SLA_ACK) && (TW_STATUS != TW_MR_SLA_ACK) ) | ||
63 | return 1; // slave did not acknowledge | ||
64 | else | ||
65 | return 0; // success | ||
66 | } | ||
67 | |||
68 | |||
69 | // Finish the i2c transaction. | ||
70 | void i2c_master_stop(void) { | ||
71 | TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO); | ||
72 | |||
73 | uint16_t lim = 0; | ||
74 | while(!(TWCR & (1<<TWSTO)) && lim < I2C_LOOP_TIMEOUT) | ||
75 | lim++; | ||
76 | } | ||
77 | |||
78 | // Write one byte to the i2c slave. | ||
79 | // returns 0 => slave ACK | ||
80 | // 1 => slave NACK | ||
81 | uint8_t i2c_master_write(uint8_t data) { | ||
82 | TWDR = data; | ||
83 | TWCR = (1<<TWINT) | (1<<TWEN); | ||
84 | |||
85 | i2c_delay(); | ||
86 | |||
87 | // check if the slave acknowledged us | ||
88 | return (TW_STATUS == TW_MT_DATA_ACK) ? 0 : 1; | ||
89 | } | ||
90 | |||
91 | // Read one byte from the i2c slave. If ack=1 the slave is acknowledged, | ||
92 | // if ack=0 the acknowledge bit is not set. | ||
93 | // returns: byte read from i2c device | ||
94 | uint8_t i2c_master_read(int ack) { | ||
95 | TWCR = (1<<TWINT) | (1<<TWEN) | (ack<<TWEA); | ||
96 | |||
97 | i2c_delay(); | ||
98 | return TWDR; | ||
99 | } | ||
100 | |||
101 | void i2c_reset_state(void) { | ||
102 | TWCR = 0; | ||
103 | } | ||
104 | |||
105 | void i2c_slave_init(uint8_t address) { | ||
106 | TWAR = address << 0; // slave i2c address | ||
107 | // TWEN - twi enable | ||
108 | // TWEA - enable address acknowledgement | ||
109 | // TWINT - twi interrupt flag | ||
110 | // TWIE - enable the twi interrupt | ||
111 | TWCR = (1<<TWIE) | (1<<TWEA) | (1<<TWINT) | (1<<TWEN); | ||
112 | } | ||
113 | |||
114 | ISR(TWI_vect); | ||
115 | |||
116 | ISR(TWI_vect) { | ||
117 | uint8_t ack = 1; | ||
118 | switch(TW_STATUS) { | ||
119 | case TW_SR_SLA_ACK: | ||
120 | // this device has been addressed as a slave receiver | ||
121 | slave_has_register_set = false; | ||
122 | break; | ||
123 | |||
124 | case TW_SR_DATA_ACK: | ||
125 | // this device has received data as a slave receiver | ||
126 | // The first byte that we receive in this transaction sets the location | ||
127 | // of the read/write location of the slaves memory that it exposes over | ||
128 | // i2c. After that, bytes will be written at slave_buffer_pos, incrementing | ||
129 | // slave_buffer_pos after each write. | ||
130 | if(!slave_has_register_set) { | ||
131 | slave_buffer_pos = TWDR; | ||
132 | // don't acknowledge the master if this memory loctaion is out of bounds | ||
133 | if ( slave_buffer_pos >= SLAVE_BUFFER_SIZE ) { | ||
134 | ack = 0; | ||
135 | slave_buffer_pos = 0; | ||
136 | } | ||
137 | slave_has_register_set = true; | ||
138 | } else { | ||
139 | i2c_slave_buffer[slave_buffer_pos] = TWDR; | ||
140 | BUFFER_POS_INC(); | ||
141 | } | ||
142 | break; | ||
143 | |||
144 | case TW_ST_SLA_ACK: | ||
145 | case TW_ST_DATA_ACK: | ||
146 | // master has addressed this device as a slave transmitter and is | ||
147 | // requesting data. | ||
148 | TWDR = i2c_slave_buffer[slave_buffer_pos]; | ||
149 | BUFFER_POS_INC(); | ||
150 | break; | ||
151 | |||
152 | case TW_BUS_ERROR: // something went wrong, reset twi state | ||
153 | TWCR = 0; | ||
154 | default: | ||
155 | break; | ||
156 | } | ||
157 | // Reset everything, so we are ready for the next TWI interrupt | ||
158 | TWCR |= (1<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN); | ||
159 | } | ||
diff --git a/keyboards/dc01/left/i2c.h b/keyboards/dc01/left/i2c.h new file mode 100644 index 000000000..0d93e4eca --- /dev/null +++ b/keyboards/dc01/left/i2c.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include <stdint.h> | ||
4 | |||
5 | #ifndef F_CPU | ||
6 | #define F_CPU 16000000UL | ||
7 | #endif | ||
8 | |||
9 | #define I2C_READ 1 | ||
10 | #define I2C_WRITE 0 | ||
11 | |||
12 | #define I2C_ACK 1 | ||
13 | #define I2C_NACK 0 | ||
14 | |||
15 | #define SLAVE_BUFFER_SIZE 0x10 | ||
16 | |||
17 | // i2c SCL clock frequency | ||
18 | #define SCL_CLOCK 400000L | ||
19 | |||
20 | extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; | ||
21 | |||
22 | void i2c_master_init(void); | ||
23 | uint8_t i2c_master_start(uint8_t address); | ||
24 | void i2c_master_stop(void); | ||
25 | uint8_t i2c_master_write(uint8_t data); | ||
26 | uint8_t i2c_master_read(int); | ||
27 | void i2c_reset_state(void); | ||
28 | void i2c_slave_init(uint8_t address); | ||
diff --git a/keyboards/dc01/left/info.json b/keyboards/dc01/left/info.json new file mode 100644 index 000000000..c2bc9337c --- /dev/null +++ b/keyboards/dc01/left/info.json | |||
@@ -0,0 +1,13 @@ | |||
1 | { | ||
2 | "keyboard_name": "DC01 Left Half", | ||
3 | "url": "", | ||
4 | "maintainer": "Yiancar-Designs", | ||
5 | "layouts": { | ||
6 | "LAYOUT_ansi": { | ||
7 | "layout": [{"label":"Esc", "x":0, "y":0}, {"label":"!", "x":1, "y":0}, {"label":"\"", "x":2, "y":0}, {"label":"\u00a3", "x":3, "y":0}, {"label":"$", "x":4, "y":0}, {"label":"%", "x":5, "y":0}, {"label":"^", "x":6, "y":0}, {"label":"&", "x":7, "y":0}, {"label":"*", "x":8, "y":0}, {"label":"(", "x":9, "y":0}, {"label":")", "x":10, "y":0}, {"label":"_", "x":11, "y":0}, {"label":"+", "x":12, "y":0}, {"label":"Back", "x":13, "y":0}, {"label":"Del", "x":14, "y":0}, {"label":"Insert", "x":15.25, "y":0}, {"label":"Home", "x":16.25, "y":0}, {"label":"PgUp", "x":17.25, "y":0}, {"label":"Num Lock", "x":18.5, "y":0}, {"label":"/", "x":19.5, "y":0}, {"label":"*", "x":20.5, "y":0}, {"label":"-", "x":21.5, "y":0}, {"label":"Tab", "x":0, "y":1, "w":1.5}, {"label":"Q", "x":1.5, "y":1}, {"label":"W", "x":2.5, "y":1}, {"label":"E", "x":3.5, "y":1}, {"label":"R", "x":4.5, "y":1}, {"label":"T", "x":5.5, "y":1}, {"label":"Y", "x":6.5, "y":1}, {"label":"U", "x":7.5, "y":1}, {"label":"I", "x":8.5, "y":1}, {"label":"O", "x":9.5, "y":1}, {"label":"P", "x":10.5, "y":1}, {"label":"{", "x":11.5, "y":1}, {"label":"}", "x":12.5, "y":1}, {"label":"|", "x":13.5, "y":1, "w":1.5}, {"label":"Delete", "x":15.25, "y":1}, {"label":"End", "x":16.25, "y":1}, {"label":"PgDn", "x":17.25, "y":1}, {"label":"7", "x":18.5, "y":1}, {"label":"8", "x":19.5, "y":1}, {"label":"9", "x":20.5, "y":1}, {"label":"+", "x":21.5, "y":1}, {"label":"Caps Lock", "x":0, "y":2, "w":1.75}, {"label":"A", "x":1.75, "y":2}, {"label":"S", "x":2.75, "y":2}, {"label":"D", "x":3.75, "y":2}, {"label":"F", "x":4.75, "y":2}, {"label":"G", "x":5.75, "y":2}, {"label":"H", "x":6.75, "y":2}, {"label":"J", "x":7.75, "y":2}, {"label":"K", "x":8.75, "y":2}, {"label":"L", "x":9.75, "y":2}, {"label":":", "x":10.75, "y":2}, {"label":"@", "x":11.75, "y":2}, {"label":"Enter", "x":12.75, "y":2, "w":2.25}, {"label":"4", "x":18.5, "y":2}, {"label":"5", "x":19.5, "y":2}, {"label":"6", "x":20.5, "y":2}, {"label":"+", "x":21.5, "y":2}, {"label":"Shift", "x":0, "y":3, "w":2.25}, {"label":"Z", "x":2.25, "y":3}, {"label":"X", "x":3.25, "y":3}, {"label":"C", "x":4.25, "y":3}, {"label":"V", "x":5.25, "y":3}, {"label":"B", "x":6.25, "y":3}, {"label":"N", "x":7.25, "y":3}, {"label":"M", "x":8.25, "y":3}, {"label":"<", "x":9.25, "y":3}, {"label":">", "x":10.25, "y":3}, {"label":"?", "x":11.25, "y":3}, {"label":"Shift", "x":12.25, "y":3, "w":1.75}, {"label":"Shift", "x":14, "y":3}, {"label":"\u2191", "x":16.25, "y":3}, {"label":"1", "x":18.5, "y":3}, {"label":"2", "x":19.5, "y":3}, {"label":"3", "x":20.5, "y":3}, {"label":"Enter", "x":21.5, "y":3}, {"label":"Ctrl", "x":0, "y":4, "w":1.25}, {"label":"Win", "x":1.25, "y":4, "w":1.25}, {"label":"Alt", "x":2.5, "y":4, "w":1.25}, {"x":3.75, "y":4, "w":2.75}, {"label":"Fn", "x":6.5, "y":4, "w":1.25}, {"x":7.75, "y":4, "w":2.25}, {"label":"AltGr", "x":10, "y":4, "w":1.25}, {"label":"Win", "x":11.25, "y":4, "w":1.25}, {"label":"Menu", "x":12.5, "y":4, "w":1.25}, {"label":"Ctrl", "x":13.75, "y":4, "w":1.25}, {"label":"\u2190", "x":15.25, "y":4}, {"label":"\u2193", "x":16.25, "y":4}, {"label":"\u2192", "x":17.25, "y":4}, {"label":"0", "x":18.5, "y":4}, {"label":"00", "x":19.5, "y":4}, {"label":".", "x":20.5, "y":4}, {"label":"Enter", "x":21.5, "y":4}] | ||
8 | }, | ||
9 | "LAYOUT_all": { | ||
10 | "layout": [{"label":"Esc", "x":0, "y":0}, {"label":"!", "x":1, "y":0}, {"label":"\"", "x":2, "y":0}, {"label":"\u00a3", "x":3, "y":0}, {"label":"$", "x":4, "y":0}, {"label":"%", "x":5, "y":0}, {"label":"^", "x":6, "y":0}, {"label":"&", "x":7, "y":0}, {"label":"*", "x":8, "y":0}, {"label":"(", "x":9, "y":0}, {"label":")", "x":10, "y":0}, {"label":"_", "x":11, "y":0}, {"label":"+", "x":12, "y":0}, {"label":"Back", "x":13, "y":0}, {"label":"Del", "x":14, "y":0}, {"label":"Insert", "x":15.25, "y":0}, {"label":"Home", "x":16.25, "y":0}, {"label":"PgUp", "x":17.25, "y":0}, {"label":"Num Lock", "x":18.5, "y":0}, {"label":"/", "x":19.5, "y":0}, {"label":"*", "x":20.5, "y":0}, {"label":"-", "x":21.5, "y":0}, {"label":"Tab", "x":0, "y":1, "w":1.5}, {"label":"Q", "x":1.5, "y":1}, {"label":"W", "x":2.5, "y":1}, {"label":"E", "x":3.5, "y":1}, {"label":"R", "x":4.5, "y":1}, {"label":"T", "x":5.5, "y":1}, {"label":"Y", "x":6.5, "y":1}, {"label":"U", "x":7.5, "y":1}, {"label":"I", "x":8.5, "y":1}, {"label":"O", "x":9.5, "y":1}, {"label":"P", "x":10.5, "y":1}, {"label":"{", "x":11.5, "y":1}, {"label":"}", "x":12.5, "y":1}, {"label":"|", "x":13.5, "y":1, "w":1.5}, {"label":"Delete", "x":15.25, "y":1}, {"label":"End", "x":16.25, "y":1}, {"label":"PgDn", "x":17.25, "y":1}, {"label":"7", "x":18.5, "y":1}, {"label":"8", "x":19.5, "y":1}, {"label":"9", "x":20.5, "y":1}, {"label":"+", "x":21.5, "y":1}, {"label":"Caps Lock", "x":0, "y":2, "w":1.75}, {"label":"A", "x":1.75, "y":2}, {"label":"S", "x":2.75, "y":2}, {"label":"D", "x":3.75, "y":2}, {"label":"F", "x":4.75, "y":2}, {"label":"G", "x":5.75, "y":2}, {"label":"H", "x":6.75, "y":2}, {"label":"J", "x":7.75, "y":2}, {"label":"K", "x":8.75, "y":2}, {"label":"L", "x":9.75, "y":2}, {"label":":", "x":10.75, "y":2}, {"label":"@", "x":11.75, "y":2}, {"label":"~", "x":12.75, "y":2}, {"label":"Enter", "x":13.75, "y":2, "w":1.25}, {"label":"4", "x":18.5, "y":2}, {"label":"5", "x":19.5, "y":2}, {"label":"6", "x":20.5, "y":2}, {"label":"+", "x":21.5, "y":2}, {"label":"Shift", "x":0, "y":3, "w":1.25}, {"label":"|", "x":1.25, "y":3}, {"label":"Z", "x":2.25, "y":3}, {"label":"X", "x":3.25, "y":3}, {"label":"C", "x":4.25, "y":3}, {"label":"V", "x":5.25, "y":3}, {"label":"B", "x":6.25, "y":3}, {"label":"N", "x":7.25, "y":3}, {"label":"M", "x":8.25, "y":3}, {"label":"<", "x":9.25, "y":3}, {"label":">", "x":10.25, "y":3}, {"label":"?", "x":11.25, "y":3}, {"label":"Shift", "x":12.25, "y":3, "w":1.75}, {"label":"Shift", "x":14, "y":3}, {"label":"\u2191", "x":16.25, "y":3}, {"label":"1", "x":18.5, "y":3}, {"label":"2", "x":19.5, "y":3}, {"label":"3", "x":20.5, "y":3}, {"label":"Enter", "x":21.5, "y":3}, {"label":"Ctrl", "x":0, "y":4, "w":1.25}, {"label":"Win", "x":1.25, "y":4, "w":1.25}, {"label":"Alt", "x":2.5, "y":4, "w":1.25}, {"x":3.75, "y":4, "w":2.75}, {"label":"Fn", "x":6.5, "y":4, "w":1.25}, {"x":7.75, "y":4, "w":2.25}, {"label":"AltGr", "x":10, "y":4, "w":1.25}, {"label":"Win", "x":11.25, "y":4, "w":1.25}, {"label":"Menu", "x":12.5, "y":4, "w":1.25}, {"label":"Ctrl", "x":13.75, "y":4, "w":1.25}, {"label":"\u2190", "x":15.25, "y":4}, {"label":"\u2193", "x":16.25, "y":4}, {"label":"\u2192", "x":17.25, "y":4}, {"label":"0", "x":18.5, "y":4}, {"label":"00", "x":19.5, "y":4}, {"label":".", "x":20.5, "y":4}, {"label":"Enter", "x":21.5, "y":4}] | ||
11 | } | ||
12 | } | ||
13 | } | ||
diff --git a/keyboards/dc01/left/keymaps/default/keymap.c b/keyboards/dc01/left/keymaps/default/keymap.c new file mode 100644 index 000000000..884e734d2 --- /dev/null +++ b/keyboards/dc01/left/keymaps/default/keymap.c | |||
@@ -0,0 +1,25 @@ | |||
1 | /* Copyright 2018 Yiancar | ||
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 QMK_KEYBOARD_H | ||
17 | |||
18 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
19 | [0] = LAYOUT_ansi( /* Base */ | ||
20 | KC_ESC, 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_DEL, KC_INS, KC_HOME, KC_PGUP, KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, | ||
21 | 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_DEL, KC_END, KC_PGDN, KC_P7, KC_P8, KC_P9, KC_PPLS, | ||
22 | 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, KC_NO, | ||
23 | 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_RSFT, KC_UP, KC_P1, KC_P2, KC_P3, KC_NO, | ||
24 | KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RIGHT, KC_P0, KC_NO, KC_PDOT, KC_PENT) | ||
25 | }; | ||
diff --git a/keyboards/dc01/left/keymaps/default/readme.md b/keyboards/dc01/left/keymaps/default/readme.md new file mode 100644 index 000000000..36207e511 --- /dev/null +++ b/keyboards/dc01/left/keymaps/default/readme.md | |||
@@ -0,0 +1,9 @@ | |||
1 | # The default ANSI keymap for DC01 Left | ||
2 | |||
3 | The keymap looks like a full layout keymap. | ||
4 | |||
5 | This is because the left part of the keyboard acts as the masterm coordinating all four part. | ||
6 | |||
7 | When using the keyboard to connect the other three parts, this keymap overwrites the individual keymaps of the single modules. | ||
8 | |||
9 | When using a module individually, the keymap of that module will take effect. | ||
diff --git a/keyboards/dc01/left/keymaps/via/keymap.c b/keyboards/dc01/left/keymaps/via/keymap.c new file mode 100644 index 000000000..43d29ef6d --- /dev/null +++ b/keyboards/dc01/left/keymaps/via/keymap.c | |||
@@ -0,0 +1,46 @@ | |||
1 | /* Copyright 2018 Yiancar | ||
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 QMK_KEYBOARD_H | ||
17 | |||
18 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
19 | [0] = LAYOUT_all( /* Base */ | ||
20 | KC_ESC, 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_DEL, KC_INS, KC_HOME, KC_PGUP, KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, | ||
21 | 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_DEL, KC_END, KC_PGDN, KC_P7, KC_P8, KC_P9, KC_PPLS, | ||
22 | 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_P4, KC_P5, KC_P6, KC_PPLS, | ||
23 | 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_RSFT, KC_UP, KC_P1, KC_P2, KC_P3, KC_PENT, | ||
24 | KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_RALT, KC_RGUI, KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RIGHT, KC_P0, KC_P0, KC_PDOT, KC_PENT), | ||
25 | |||
26 | [1] = LAYOUT_all( /* Empty for Dynamic keymap */ | ||
27 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
28 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
29 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
30 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
31 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), | ||
32 | |||
33 | [2] = LAYOUT_all( /* Empty for Dynamic keymap */ | ||
34 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
35 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
36 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
37 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
38 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), | ||
39 | |||
40 | [3] = LAYOUT_all( /* Empty for Dynamic keymap */ | ||
41 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
42 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
43 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
44 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, | ||
45 | KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS) | ||
46 | }; | ||
diff --git a/keyboards/dc01/left/keymaps/via/readme.md b/keyboards/dc01/left/keymaps/via/readme.md new file mode 100644 index 000000000..a2c2fb0cd --- /dev/null +++ b/keyboards/dc01/left/keymaps/via/readme.md | |||
@@ -0,0 +1,11 @@ | |||
1 | # The default VIA keymap for DC01 Left | ||
2 | |||
3 | Please use this for ISO as well. | ||
4 | |||
5 | The keymap looks like a full layout keymap. | ||
6 | |||
7 | This is because the left part of the keyboard acts as the masterm coordinating all four part. | ||
8 | |||
9 | When using the keyboard to connect the other three parts, this keymap overwrites the individual keymaps of the single modules. | ||
10 | |||
11 | When using a module individually, the keymap of that module will take effect. | ||
diff --git a/keyboards/dc01/left/keymaps/via/rules.mk b/keyboards/dc01/left/keymaps/via/rules.mk new file mode 100755 index 000000000..1e5b99807 --- /dev/null +++ b/keyboards/dc01/left/keymaps/via/rules.mk | |||
@@ -0,0 +1 @@ | |||
VIA_ENABLE = yes | |||
diff --git a/keyboards/dc01/left/left.c b/keyboards/dc01/left/left.c new file mode 100644 index 000000000..b10121705 --- /dev/null +++ b/keyboards/dc01/left/left.c | |||
@@ -0,0 +1,16 @@ | |||
1 | /* Copyright 2018 Yiancar | ||
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 "left.h" | ||
diff --git a/keyboards/dc01/left/left.h b/keyboards/dc01/left/left.h new file mode 100644 index 000000000..4fbd7a7e5 --- /dev/null +++ b/keyboards/dc01/left/left.h | |||
@@ -0,0 +1,48 @@ | |||
1 | /* Copyright 2018 Yiancar | ||
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 | |||
20 | #define XXX KC_NO | ||
21 | |||
22 | #define LAYOUT_all( \ | ||
23 | K00, K01, K02, K03, K04, K05, K45, K07, K08, K09, K0A, K0B, K0C, K0D, K06, K0E, K0F, K0G, K0H, K0J, K0K, K0L, \ | ||
24 | K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1J, K1K, K1L, \ | ||
25 | K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2H, K2J, K2K, K2L, \ | ||
26 | K30, K44, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3C, K3D, K3F, K3H, K3J, K3K, K3L, \ | ||
27 | K40, K41, K42, K43, K46, K47, K48, K49, K4A, K4B, K4E, K4F, K4G, K4H, K4J, K4K, K4L \ | ||
28 | ) { \ | ||
29 | { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, K0H, K0J, K0K, K0L }, \ | ||
30 | { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1J, K1K, K1L }, \ | ||
31 | { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, XXX, XXX, XXX, K2H, K2J, K2K, K2L }, \ | ||
32 | { K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, XXX, K3C, K3D, XXX, K3F, XXX, K3H, K3J, K3K, K3L }, \ | ||
33 | { K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4B, XXX, XXX, K4E, K4F, K4G, K4H, K4J, K4K, K4L } \ | ||
34 | } | ||
35 | |||
36 | #define LAYOUT_ansi( \ | ||
37 | K00, K01, K02, K03, K04, K05, K45, K07, K08, K09, K0A, K0B, K0C, K0D, K06, K0E, K0F, K0G, K0H, K0J, K0K, K0L, \ | ||
38 | K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1J, K1K, K1L, \ | ||
39 | K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2D, K2H, K2J, K2K, K2L, \ | ||
40 | K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3C, K3D, K3F, K3H, K3J, K3K, K3L, \ | ||
41 | K40, K41, K42, K43, K46, K47, K48, K49, K4A, K4B, K4E, K4F, K4G, K4H, K4J, K4K, K4L \ | ||
42 | ) { \ | ||
43 | { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K0F, K0G, K0H, K0J, K0K, K0L }, \ | ||
44 | { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1J, K1K, K1L }, \ | ||
45 | { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, XXX, K2D, XXX, XXX, XXX, K2H, K2J, K2K, K2L }, \ | ||
46 | { K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, XXX, K3C, K3D, XXX, K3F, XXX, K3H, K3J, K3K, K3L }, \ | ||
47 | { K40, K41, K42, K43, XXX, K45, K46, K47, K48, K49, K4A, K4B, XXX, XXX, K4E, K4F, K4G, K4H, K4J, K4K, K4L } \ | ||
48 | } | ||
diff --git a/keyboards/dc01/left/matrix.c b/keyboards/dc01/left/matrix.c new file mode 100644 index 000000000..bf5aba849 --- /dev/null +++ b/keyboards/dc01/left/matrix.c | |||
@@ -0,0 +1,455 @@ | |||
1 | /* | ||
2 | Copyright 2012 Jun Wako | ||
3 | Copyright 2014 Jack Humbert | ||
4 | |||
5 | This program is free software: you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation, either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | #include <stdint.h> | ||
19 | #include <stdbool.h> | ||
20 | #if defined(__AVR__) | ||
21 | #include <avr/io.h> | ||
22 | #include <avr/wdt.h> | ||
23 | #include <avr/interrupt.h> | ||
24 | #include <util/delay.h> | ||
25 | #endif | ||
26 | #include "wait.h" | ||
27 | #include "print.h" | ||
28 | #include "debug.h" | ||
29 | #include "gpio.h" | ||
30 | #include "util.h" | ||
31 | #include "matrix.h" | ||
32 | #include "timer.h" | ||
33 | #include "i2c_master.h" | ||
34 | |||
35 | #define SLAVE_I2C_ADDRESS_RIGHT 0x32 | ||
36 | #define SLAVE_I2C_ADDRESS_NUMPAD 0x36 | ||
37 | #define SLAVE_I2C_ADDRESS_ARROW 0x40 | ||
38 | |||
39 | #define ERROR_DISCONNECT_COUNT 5 | ||
40 | |||
41 | /* Set 0 if debouncing isn't needed */ | ||
42 | |||
43 | #ifndef DEBOUNCE | ||
44 | # define DEBOUNCE 5 | ||
45 | #endif | ||
46 | |||
47 | #if (DEBOUNCE > 0) | ||
48 | static uint16_t debouncing_time; | ||
49 | static bool debouncing = false; | ||
50 | #endif | ||
51 | |||
52 | #if (MATRIX_COLS <= 8) | ||
53 | # define print_matrix_header() print("\nr/c 01234567\n") | ||
54 | # define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) | ||
55 | # define matrix_bitpop(i) bitpop(matrix[i]) | ||
56 | # define ROW_SHIFTER ((uint8_t)1) | ||
57 | #elif (MATRIX_COLS <= 16) | ||
58 | # define print_matrix_header() print("\nr/c 0123456789ABCDEF\n") | ||
59 | # define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row)) | ||
60 | # define matrix_bitpop(i) bitpop16(matrix[i]) | ||
61 | # define ROW_SHIFTER ((uint16_t)1) | ||
62 | #elif (MATRIX_COLS <= 32) | ||
63 | # define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n") | ||
64 | # define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row)) | ||
65 | # define matrix_bitpop(i) bitpop32(matrix[i]) | ||
66 | # define ROW_SHIFTER ((uint32_t)1) | ||
67 | #endif | ||
68 | |||
69 | #ifdef MATRIX_MASKED | ||
70 | extern const matrix_row_t matrix_mask[]; | ||
71 | #endif | ||
72 | |||
73 | #if (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW) | ||
74 | static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; | ||
75 | static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; | ||
76 | #endif | ||
77 | |||
78 | /* matrix state(1:on, 0:off) */ | ||
79 | static matrix_row_t matrix[MATRIX_ROWS]; | ||
80 | |||
81 | static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | ||
82 | |||
83 | |||
84 | #if (DIODE_DIRECTION == COL2ROW) | ||
85 | static void init_cols(void); | ||
86 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row); | ||
87 | static void unselect_rows(void); | ||
88 | static void select_row(uint8_t row); | ||
89 | static void unselect_row(uint8_t row); | ||
90 | #elif (DIODE_DIRECTION == ROW2COL) | ||
91 | static void init_rows(void); | ||
92 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col); | ||
93 | static void unselect_cols(void); | ||
94 | static void unselect_col(uint8_t col); | ||
95 | static void select_col(uint8_t col); | ||
96 | #endif | ||
97 | |||
98 | __attribute__ ((weak)) | ||
99 | void matrix_init_quantum(void) { | ||
100 | matrix_init_kb(); | ||
101 | } | ||
102 | |||
103 | __attribute__ ((weak)) | ||
104 | void matrix_scan_quantum(void) { | ||
105 | matrix_scan_kb(); | ||
106 | } | ||
107 | |||
108 | __attribute__ ((weak)) | ||
109 | void matrix_init_kb(void) { | ||
110 | matrix_init_user(); | ||
111 | } | ||
112 | |||
113 | __attribute__ ((weak)) | ||
114 | void matrix_scan_kb(void) { | ||
115 | matrix_scan_user(); | ||
116 | } | ||
117 | |||
118 | __attribute__ ((weak)) | ||
119 | void matrix_init_user(void) { | ||
120 | } | ||
121 | |||
122 | __attribute__ ((weak)) | ||
123 | void matrix_scan_user(void) { | ||
124 | } | ||
125 | |||
126 | inline | ||
127 | uint8_t matrix_rows(void) { | ||
128 | return MATRIX_ROWS; | ||
129 | } | ||
130 | |||
131 | inline | ||
132 | uint8_t matrix_cols(void) { | ||
133 | return MATRIX_COLS; | ||
134 | } | ||
135 | |||
136 | i2c_status_t i2c_transaction(uint8_t address, uint32_t mask, uint8_t col_offset); | ||
137 | |||
138 | //this replases tmk code | ||
139 | void matrix_setup(void){ | ||
140 | i2c_init(); | ||
141 | } | ||
142 | |||
143 | void matrix_init(void) { | ||
144 | |||
145 | // initialize row and col | ||
146 | #if (DIODE_DIRECTION == COL2ROW) | ||
147 | unselect_rows(); | ||
148 | init_cols(); | ||
149 | #elif (DIODE_DIRECTION == ROW2COL) | ||
150 | unselect_cols(); | ||
151 | init_rows(); | ||
152 | #endif | ||
153 | |||
154 | // initialize matrix state: all keys off | ||
155 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
156 | matrix[i] = 0; | ||
157 | matrix_debouncing[i] = 0; | ||
158 | } | ||
159 | |||
160 | matrix_init_quantum(); | ||
161 | } | ||
162 | |||
163 | uint8_t matrix_scan(void) | ||
164 | { | ||
165 | |||
166 | #if (DIODE_DIRECTION == COL2ROW) | ||
167 | |||
168 | // Set row, read cols | ||
169 | for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { | ||
170 | # if (DEBOUNCE > 0) | ||
171 | bool matrix_changed = read_cols_on_row(matrix_debouncing, current_row); | ||
172 | |||
173 | if (matrix_changed) { | ||
174 | debouncing = true; | ||
175 | debouncing_time = timer_read(); | ||
176 | } | ||
177 | |||
178 | # else | ||
179 | read_cols_on_row(matrix, current_row); | ||
180 | # endif | ||
181 | |||
182 | } | ||
183 | |||
184 | #elif (DIODE_DIRECTION == ROW2COL) | ||
185 | |||
186 | // Set col, read rows | ||
187 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { | ||
188 | # if (DEBOUNCE > 0) | ||
189 | bool matrix_changed = read_rows_on_col(matrix_debouncing, current_col); | ||
190 | if (matrix_changed) { | ||
191 | debouncing = true; | ||
192 | debouncing_time = timer_read(); | ||
193 | } | ||
194 | # else | ||
195 | read_rows_on_col(matrix, current_col); | ||
196 | # endif | ||
197 | |||
198 | } | ||
199 | |||
200 | #endif | ||
201 | |||
202 | # if (DEBOUNCE > 0) | ||
203 | if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCE)) { | ||
204 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
205 | matrix[i] = matrix_debouncing[i]; | ||
206 | } | ||
207 | debouncing = false; | ||
208 | } | ||
209 | # endif | ||
210 | |||
211 | if (i2c_transaction(SLAVE_I2C_ADDRESS_RIGHT, 0x3F, 0)) { | ||
212 | for (uint8_t i = 0; i < MATRIX_ROWS ; i++) { | ||
213 | matrix[i] &= 0x3F; //mask bits to keep | ||
214 | } | ||
215 | } | ||
216 | |||
217 | if (i2c_transaction(SLAVE_I2C_ADDRESS_ARROW, 0X3FFF, 8)) { | ||
218 | for (uint8_t i = 0; i < MATRIX_ROWS ; i++) { | ||
219 | matrix[i] &= 0x3FFF; //mask bits to keep | ||
220 | } | ||
221 | } | ||
222 | |||
223 | if (i2c_transaction(SLAVE_I2C_ADDRESS_NUMPAD, 0x1FFFF, 11)) { | ||
224 | for (uint8_t i = 0; i < MATRIX_ROWS ; i++) { | ||
225 | matrix[i] &= 0x1FFFF; //mask bits to keep | ||
226 | } | ||
227 | } | ||
228 | |||
229 | matrix_scan_quantum(); | ||
230 | return 1; | ||
231 | } | ||
232 | |||
233 | bool matrix_is_modified(void) | ||
234 | { | ||
235 | #if (DEBOUNCE > 0) | ||
236 | if (debouncing) return false; | ||
237 | #endif | ||
238 | return true; | ||
239 | } | ||
240 | |||
241 | inline | ||
242 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
243 | { | ||
244 | return (matrix[row] & ((matrix_row_t)1<<col)); | ||
245 | } | ||
246 | |||
247 | inline | ||
248 | matrix_row_t matrix_get_row(uint8_t row) | ||
249 | { | ||
250 | // Matrix mask lets you disable switches in the returned matrix data. For example, if you have a | ||
251 | // switch blocker installed and the switch is always pressed. | ||
252 | #ifdef MATRIX_MASKED | ||
253 | return matrix[row] & matrix_mask[row]; | ||
254 | #else | ||
255 | return matrix[row]; | ||
256 | #endif | ||
257 | } | ||
258 | |||
259 | void matrix_print(void) | ||
260 | { | ||
261 | print_matrix_header(); | ||
262 | |||
263 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
264 | print_hex8(row); print(": "); | ||
265 | print_matrix_row(row); | ||
266 | print("\n"); | ||
267 | } | ||
268 | } | ||
269 | |||
270 | uint8_t matrix_key_count(void) | ||
271 | { | ||
272 | uint8_t count = 0; | ||
273 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
274 | count += matrix_bitpop(i); | ||
275 | } | ||
276 | return count; | ||
277 | } | ||
278 | |||
279 | |||
280 | |||
281 | #if (DIODE_DIRECTION == COL2ROW) | ||
282 | |||
283 | static void init_cols(void) | ||
284 | { | ||
285 | for(uint8_t x = 0; x < MATRIX_COLS_SCANNED; x++) { | ||
286 | uint8_t pin = col_pins[x]; | ||
287 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
288 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
289 | } | ||
290 | } | ||
291 | |||
292 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | ||
293 | { | ||
294 | // Store last value of row prior to reading | ||
295 | matrix_row_t last_row_value = current_matrix[current_row]; | ||
296 | |||
297 | // Clear data in matrix row | ||
298 | current_matrix[current_row] = 0; | ||
299 | |||
300 | // Select row and wait for row selecton to stabilize | ||
301 | select_row(current_row); | ||
302 | wait_us(30); | ||
303 | |||
304 | // For each col... | ||
305 | for(uint8_t col_index = 0; col_index < MATRIX_COLS_SCANNED; col_index++) { | ||
306 | |||
307 | // Select the col pin to read (active low) | ||
308 | uint8_t pin = col_pins[col_index]; | ||
309 | uint8_t pin_state = (_SFR_IO8(pin >> 4) & _BV(pin & 0xF)); | ||
310 | |||
311 | // Populate the matrix row with the state of the col pin | ||
312 | current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index); | ||
313 | } | ||
314 | |||
315 | // Unselect row | ||
316 | unselect_row(current_row); | ||
317 | |||
318 | return (last_row_value != current_matrix[current_row]); | ||
319 | } | ||
320 | |||
321 | static void select_row(uint8_t row) | ||
322 | { | ||
323 | uint8_t pin = row_pins[row]; | ||
324 | _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT | ||
325 | _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW | ||
326 | } | ||
327 | |||
328 | static void unselect_row(uint8_t row) | ||
329 | { | ||
330 | uint8_t pin = row_pins[row]; | ||
331 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
332 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
333 | } | ||
334 | |||
335 | static void unselect_rows(void) | ||
336 | { | ||
337 | for(uint8_t x = 0; x < MATRIX_ROWS; x++) { | ||
338 | uint8_t pin = row_pins[x]; | ||
339 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
340 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
341 | } | ||
342 | } | ||
343 | |||
344 | #elif (DIODE_DIRECTION == ROW2COL) | ||
345 | |||
346 | static void init_rows(void) | ||
347 | { | ||
348 | for(uint8_t x = 0; x < MATRIX_ROWS; x++) { | ||
349 | uint8_t pin = row_pins[x]; | ||
350 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
351 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
352 | } | ||
353 | } | ||
354 | |||
355 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) | ||
356 | { | ||
357 | bool matrix_changed = false; | ||
358 | |||
359 | // Select col and wait for col selecton to stabilize | ||
360 | select_col(current_col); | ||
361 | wait_us(30); | ||
362 | |||
363 | // For each row... | ||
364 | for(uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) | ||
365 | { | ||
366 | |||
367 | // Store last value of row prior to reading | ||
368 | matrix_row_t last_row_value = current_matrix[row_index]; | ||
369 | |||
370 | // Check row pin state | ||
371 | if ((_SFR_IO8(row_pins[row_index] >> 4) & _BV(row_pins[row_index] & 0xF)) == 0) | ||
372 | { | ||
373 | // Pin LO, set col bit | ||
374 | current_matrix[row_index] |= (ROW_SHIFTER << current_col); | ||
375 | } | ||
376 | else | ||
377 | { | ||
378 | // Pin HI, clear col bit | ||
379 | current_matrix[row_index] &= ~(ROW_SHIFTER << current_col); | ||
380 | } | ||
381 | |||
382 | // Determine if the matrix changed state | ||
383 | if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) | ||
384 | { | ||
385 | matrix_changed = true; | ||
386 | } | ||
387 | } | ||
388 | |||
389 | // Unselect col | ||
390 | unselect_col(current_col); | ||
391 | |||
392 | return matrix_changed; | ||
393 | } | ||
394 | |||
395 | static void select_col(uint8_t col) | ||
396 | { | ||
397 | uint8_t pin = col_pins[col]; | ||
398 | _SFR_IO8((pin >> 4) + 1) |= _BV(pin & 0xF); // OUT | ||
399 | _SFR_IO8((pin >> 4) + 2) &= ~_BV(pin & 0xF); // LOW | ||
400 | } | ||
401 | |||
402 | static void unselect_col(uint8_t col) | ||
403 | { | ||
404 | uint8_t pin = col_pins[col]; | ||
405 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
406 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
407 | } | ||
408 | |||
409 | static void unselect_cols(void) | ||
410 | { | ||
411 | for(uint8_t x = 0; x < MATRIX_COLS_SCANNED; x++) { | ||
412 | uint8_t pin = col_pins[x]; | ||
413 | _SFR_IO8((pin >> 4) + 1) &= ~_BV(pin & 0xF); // IN | ||
414 | _SFR_IO8((pin >> 4) + 2) |= _BV(pin & 0xF); // HI | ||
415 | } | ||
416 | } | ||
417 | |||
418 | #endif | ||
419 | |||
420 | // Complete rows from other modules over i2c | ||
421 | i2c_status_t i2c_transaction(uint8_t address, uint32_t mask, uint8_t col_offset) { | ||
422 | i2c_status_t status = i2c_start(address, 50); | ||
423 | if (status < 0) { | ||
424 | goto error; | ||
425 | } | ||
426 | |||
427 | status = i2c_write(0x01, 50); | ||
428 | if (status < 0) { | ||
429 | goto error; | ||
430 | } | ||
431 | |||
432 | status = i2c_start(address | I2C_READ, 50); | ||
433 | |||
434 | status = i2c_read_ack(50); | ||
435 | if (status != 0x55) { //synchronization byte | ||
436 | goto error; | ||
437 | } | ||
438 | |||
439 | for (uint8_t i = 0; i < MATRIX_ROWS-1 && status >= 0; i++) { //assemble slave matrix in main matrix | ||
440 | matrix[i] &= mask; //mask bits to keep | ||
441 | status = i2c_read_ack(50); | ||
442 | matrix[i] |= ((uint32_t)status << (MATRIX_COLS_SCANNED + col_offset)); //add new bits at the end | ||
443 | } | ||
444 | //last read request must be followed by a NACK | ||
445 | if (status >= 0) { | ||
446 | matrix[MATRIX_ROWS - 1] &= mask; //mask bits to keep | ||
447 | status = i2c_read_nack(50); | ||
448 | matrix[MATRIX_ROWS - 1] |= ((uint32_t)status << (MATRIX_COLS_SCANNED + col_offset)); //add new bits at the end | ||
449 | } | ||
450 | |||
451 | error: | ||
452 | i2c_stop(); | ||
453 | |||
454 | return (status < 0) ? status : I2C_STATUS_SUCCESS; | ||
455 | } | ||
diff --git a/keyboards/dc01/left/readme.md b/keyboards/dc01/left/readme.md new file mode 100644 index 000000000..60b90a800 --- /dev/null +++ b/keyboards/dc01/left/readme.md | |||
@@ -0,0 +1,15 @@ | |||
1 | # DC01 Left Half | ||
2 | |||
3 |  | ||
4 | |||
5 | A hotpluggable four part keyboard which comes together with magnets and pogo pins! This is the left part that also acts as the master. | ||
6 | |||
7 | Keyboard Maintainer: [Yiancar](https://github.com/yiancar) | ||
8 | Hardware Supported: Runs on an atmega32u4 | ||
9 | Hardware Availability: [Mechboards](https://mechboards.co.uk/) | ||
10 | |||
11 | Make example for this keyboard (after setting up your build environment): | ||
12 | |||
13 | make dc01/left:default | ||
14 | |||
15 | See [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) then the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. | ||
diff --git a/keyboards/dc01/left/rules.mk b/keyboards/dc01/left/rules.mk new file mode 100644 index 000000000..1c180d54b --- /dev/null +++ b/keyboards/dc01/left/rules.mk | |||
@@ -0,0 +1,21 @@ | |||
1 | # MCU name | ||
2 | MCU = atmega32u4 | ||
3 | |||
4 | # Bootloader selection | ||
5 | BOOTLOADER = atmel-dfu | ||
6 | |||
7 | # Build Options | ||
8 | # change yes to no to disable | ||
9 | # | ||
10 | BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite | ||
11 | MOUSEKEY_ENABLE = yes # Mouse keys | ||
12 | EXTRAKEY_ENABLE = yes # Audio control and System control | ||
13 | CONSOLE_ENABLE = no # Console for debug | ||
14 | COMMAND_ENABLE = no # Commands for debug and configuration | ||
15 | NKRO_ENABLE = yes # Enable N-Key Rollover | ||
16 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality | ||
17 | AUDIO_ENABLE = no # Audio output | ||
18 | |||
19 | CUSTOM_MATRIX = yes # Use custom matrix | ||
20 | SRC += matrix.c \ | ||
21 | i2c_master.c | ||