aboutsummaryrefslogtreecommitdiff
path: root/keyboards/zinc
diff options
context:
space:
mode:
authorJames Young <18669334+noroadsleft@users.noreply.github.com>2020-05-30 13:14:59 -0700
committerGitHub <noreply@github.com>2020-05-30 13:14:59 -0700
commitfced377ac007d27f2650ccffbe0b18abcdcfe23d (patch)
treebd5b141987394a5a16cfc416bfe2b9efdb14d067 /keyboards/zinc
parent7b8a013826ad90714a05ea522de53adf964ab3b9 (diff)
downloadqmk_firmware-fced377ac007d27f2650ccffbe0b18abcdcfe23d.tar.gz
qmk_firmware-fced377ac007d27f2650ccffbe0b18abcdcfe23d.zip
2020 May 30 Breaking Changes Update (#9215)
* Branch point for 2020 May 30 Breaking Change * Migrate `ACTION_LAYER_TOGGLE` to `TG()` (#8954) * Migrate `ACTION_MODS_ONESHOT` to `OSM()` (#8957) * Migrate `ACTION_DEFAULT_LAYER_SET` to `DF()` (#8958) * Migrate `ACTION_LAYER_MODS` to `LM()` (#8959) * Migrate `ACTION_MODS_TAP_KEY` to `MT()` (#8968) * Convert V-USB usbdrv to a submodule (#8321) * Unify Tap Hold functions and documentation (#8348) * Changing board names to prevent confusion (#8412) * Move the Keyboardio Model01 to a keyboardio/ subdir (#8499) * Move spaceman keyboards (#8830) * Migrate miscellaneous `fn_actions` entries (#8977) * Migrate `ACTION_MODS_KEY` to chained mod keycodes (#8979) * Organizing my keyboards (plaid, tartan, ergoinu) (#8537) * Refactor Lily58 to use split_common (#6260) * Refactor zinc to use split_common (#7114) * Add a message if bin/qmk doesn't work (#9000) * Fix conflicting types for 'tfp_printf' (#8269) * Fixed RGB_DISABLE_AFTER_TIMEOUT to be seconds based & small internals cleanup (#6480) * Refactor and updates to TKC1800 code (#8472) * Switch to qmk forks for everything (#9019) * audio refactor: replace deprecated PLAY_NOTE_ARRAY (#8484) * Audio enable corrections (2/3) (#8903) * Split HHKB to ANSI and JP layouts and Add VIA support for each (#8582) * Audio enable corrections (Part 4) (#8974) * Fix typo from PR7114 (#9171) * Augment future branch Changelogs (#8978) * Revert "Branch point for 2020 May 30 Breaking Change"
Diffstat (limited to 'keyboards/zinc')
-rw-r--r--keyboards/zinc/config.h25
-rw-r--r--keyboards/zinc/i2c.c162
-rw-r--r--keyboards/zinc/i2c.h49
-rw-r--r--keyboards/zinc/keymaps/default/config.h2
-rw-r--r--keyboards/zinc/keymaps/default/keymap.c26
-rw-r--r--keyboards/zinc/keymaps/default/readme_en.md131
-rw-r--r--keyboards/zinc/keymaps/default/readme_jp.md48
-rw-r--r--keyboards/zinc/keymaps/default/rules.mk57
-rw-r--r--keyboards/zinc/keymaps/ginjake/config.h2
-rw-r--r--keyboards/zinc/keymaps/ginjake/rules.mk48
-rw-r--r--keyboards/zinc/keymaps/monks/config.h2
-rw-r--r--keyboards/zinc/keymaps/monks/keymap.c3
-rw-r--r--keyboards/zinc/keymaps/monks/readme_jp.md2
-rw-r--r--keyboards/zinc/keymaps/monks/rules.mk50
-rw-r--r--keyboards/zinc/keymaps/toshi0383/config.h2
-rw-r--r--keyboards/zinc/keymaps/toshi0383/rules.mk67
-rw-r--r--keyboards/zinc/readme.md6
-rw-r--r--keyboards/zinc/rev1/config.h61
-rw-r--r--keyboards/zinc/rev1/matrix.c357
-rw-r--r--keyboards/zinc/rev1/rev1.c1
-rw-r--r--keyboards/zinc/rev1/rev1.h15
-rw-r--r--keyboards/zinc/rev1/rules.mk5
-rw-r--r--keyboards/zinc/rev1/serial_config.h18
-rw-r--r--keyboards/zinc/rev1/serial_config_simpleapi.h8
-rw-r--r--keyboards/zinc/rev1/split_scomm.c95
-rw-r--r--keyboards/zinc/rev1/split_scomm.h24
-rw-r--r--keyboards/zinc/rev1/split_util.c70
-rw-r--r--keyboards/zinc/rev1/split_util.h19
-rw-r--r--keyboards/zinc/reva/config.h56
-rw-r--r--keyboards/zinc/reva/matrix.c357
-rw-r--r--keyboards/zinc/reva/reva.c1
-rw-r--r--keyboards/zinc/reva/reva.h15
-rw-r--r--keyboards/zinc/reva/rules.mk5
-rw-r--r--keyboards/zinc/reva/serial_config.h18
-rw-r--r--keyboards/zinc/reva/serial_config_simpleapi.h8
-rw-r--r--keyboards/zinc/reva/split_scomm.c95
-rw-r--r--keyboards/zinc/reva/split_scomm.h24
-rw-r--r--keyboards/zinc/reva/split_util.c70
-rw-r--r--keyboards/zinc/reva/split_util.h19
-rw-r--r--keyboards/zinc/rules.mk4
-rw-r--r--keyboards/zinc/serial.c589
-rw-r--r--keyboards/zinc/serial.h84
-rw-r--r--keyboards/zinc/zinc.h6
43 files changed, 443 insertions, 2263 deletions
diff --git a/keyboards/zinc/config.h b/keyboards/zinc/config.h
index 712db0ac6..cfb6bf4ff 100644
--- a/keyboards/zinc/config.h
+++ b/keyboards/zinc/config.h
@@ -17,30 +17,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/ 17*/
18 18
19#pragma once 19#pragma once
20//#ifndef CONFIG_H
21//#define CONFIG_H
22 20
23#include "config_common.h" 21#include "config_common.h"
24
25// GCC include 'config.h" sequence in qmk_firmware/keyboards/zinc/
26// -include keyboards/zinc/config.h
27// -include keyboards/zinc/rev?/config.h
28// -include keyboards/zinc/rev?/keymaps/MAPNAME/config.h
29// XXXX.c
30
31#include <serial_config.h>
32
33// GCC include search path in qmk_firmare/keyboards/zinc/
34// #include "..." search starts here:
35// #include <...> search starts here:
36// keyboards/zinc/rev?/keymaps/MAPNAME
37// keyboards/zinc
38// keyboards/zinc/rev?
39// .
40// ./tmk_core
41// ......
42
43#define NO_ACTION_MACRO
44#define NO_ACTION_FUNCTION
45
46//#endif /* CONFIG_H */
diff --git a/keyboards/zinc/i2c.c b/keyboards/zinc/i2c.c
deleted file mode 100644
index 4bee5c639..000000000
--- a/keyboards/zinc/i2c.c
+++ /dev/null
@@ -1,162 +0,0 @@
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#ifdef USE_I2C
10
11// Limits the amount of we wait for any one i2c transaction.
12// Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is
13// 9 bits, a single transaction will take around 90μs to complete.
14//
15// (F_CPU/SCL_CLOCK) => # of μC cycles to transfer a bit
16// poll loop takes at least 8 clock cycles to execute
17#define I2C_LOOP_TIMEOUT (9+1)*(F_CPU/SCL_CLOCK)/8
18
19#define BUFFER_POS_INC() (slave_buffer_pos = (slave_buffer_pos+1)%SLAVE_BUFFER_SIZE)
20
21volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];
22
23static volatile uint8_t slave_buffer_pos;
24static volatile bool slave_has_register_set = false;
25
26// Wait for an i2c operation to finish
27inline static
28void i2c_delay(void) {
29 uint16_t lim = 0;
30 while(!(TWCR & (1<<TWINT)) && lim < I2C_LOOP_TIMEOUT)
31 lim++;
32
33 // easier way, but will wait slightly longer
34 // _delay_us(100);
35}
36
37// Setup twi to run at 100kHz or 400kHz (see ./i2c.h SCL_CLOCK)
38void i2c_master_init(void) {
39 // no prescaler
40 TWSR = 0;
41 // Set TWI clock frequency to SCL_CLOCK. Need TWBR>10.
42 // Check datasheets for more info.
43 TWBR = ((F_CPU/SCL_CLOCK)-16)/2;
44}
45
46// Start a transaction with the given i2c slave address. The direction of the
47// transfer is set with I2C_READ and I2C_WRITE.
48// returns: 0 => success
49// 1 => error
50uint8_t i2c_master_start(uint8_t address) {
51 TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTA);
52
53 i2c_delay();
54
55 // check that we started successfully
56 if ( (TW_STATUS != TW_START) && (TW_STATUS != TW_REP_START))
57 return 1;
58
59 TWDR = address;
60 TWCR = (1<<TWINT) | (1<<TWEN);
61
62 i2c_delay();
63
64 if ( (TW_STATUS != TW_MT_SLA_ACK) && (TW_STATUS != TW_MR_SLA_ACK) )
65 return 1; // slave did not acknowledge
66 else
67 return 0; // success
68}
69
70
71// Finish the i2c transaction.
72void i2c_master_stop(void) {
73 TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
74
75 uint16_t lim = 0;
76 while(!(TWCR & (1<<TWSTO)) && lim < I2C_LOOP_TIMEOUT)
77 lim++;
78}
79
80// Write one byte to the i2c slave.
81// returns 0 => slave ACK
82// 1 => slave NACK
83uint8_t i2c_master_write(uint8_t data) {
84 TWDR = data;
85 TWCR = (1<<TWINT) | (1<<TWEN);
86
87 i2c_delay();
88
89 // check if the slave acknowledged us
90 return (TW_STATUS == TW_MT_DATA_ACK) ? 0 : 1;
91}
92
93// Read one byte from the i2c slave. If ack=1 the slave is acknowledged,
94// if ack=0 the acknowledge bit is not set.
95// returns: byte read from i2c device
96uint8_t i2c_master_read(int ack) {
97 TWCR = (1<<TWINT) | (1<<TWEN) | (ack<<TWEA);
98
99 i2c_delay();
100 return TWDR;
101}
102
103void i2c_reset_state(void) {
104 TWCR = 0;
105}
106
107void i2c_slave_init(uint8_t address) {
108 TWAR = address << 0; // slave i2c address
109 // TWEN - twi enable
110 // TWEA - enable address acknowledgement
111 // TWINT - twi interrupt flag
112 // TWIE - enable the twi interrupt
113 TWCR = (1<<TWIE) | (1<<TWEA) | (1<<TWINT) | (1<<TWEN);
114}
115
116ISR(TWI_vect);
117
118ISR(TWI_vect) {
119 uint8_t ack = 1;
120 switch(TW_STATUS) {
121 case TW_SR_SLA_ACK:
122 // this device has been addressed as a slave receiver
123 slave_has_register_set = false;
124 break;
125
126 case TW_SR_DATA_ACK:
127 // this device has received data as a slave receiver
128 // The first byte that we receive in this transaction sets the location
129 // of the read/write location of the slaves memory that it exposes over
130 // i2c. After that, bytes will be written at slave_buffer_pos, incrementing
131 // slave_buffer_pos after each write.
132 if(!slave_has_register_set) {
133 slave_buffer_pos = TWDR;
134 // don't acknowledge the master if this memory loctaion is out of bounds
135 if ( slave_buffer_pos >= SLAVE_BUFFER_SIZE ) {
136 ack = 0;
137 slave_buffer_pos = 0;
138 }
139 slave_has_register_set = true;
140 } else {
141 i2c_slave_buffer[slave_buffer_pos] = TWDR;
142 BUFFER_POS_INC();
143 }
144 break;
145
146 case TW_ST_SLA_ACK:
147 case TW_ST_DATA_ACK:
148 // master has addressed this device as a slave transmitter and is
149 // requesting data.
150 TWDR = i2c_slave_buffer[slave_buffer_pos];
151 BUFFER_POS_INC();
152 break;
153
154 case TW_BUS_ERROR: // something went wrong, reset twi state
155 TWCR = 0;
156 default:
157 break;
158 }
159 // Reset everything, so we are ready for the next TWI interrupt
160 TWCR |= (1<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN);
161}
162#endif
diff --git a/keyboards/zinc/i2c.h b/keyboards/zinc/i2c.h
deleted file mode 100644
index 47cf6bd1b..000000000
--- a/keyboards/zinc/i2c.h
+++ /dev/null
@@ -1,49 +0,0 @@
1#ifndef I2C_H
2#define I2C_H
3
4#include <stdint.h>
5
6#ifndef F_CPU
7#define F_CPU 16000000UL
8#endif
9
10#define I2C_READ 1
11#define I2C_WRITE 0
12
13#define I2C_ACK 1
14#define I2C_NACK 0
15
16#define SLAVE_BUFFER_SIZE 0x10
17
18// i2c SCL clock frequency 400kHz
19#define SCL_CLOCK 400000L
20
21extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];
22
23void i2c_master_init(void);
24uint8_t i2c_master_start(uint8_t address);
25void i2c_master_stop(void);
26uint8_t i2c_master_write(uint8_t data);
27uint8_t i2c_master_read(int);
28void i2c_reset_state(void);
29void i2c_slave_init(uint8_t address);
30
31
32static inline unsigned char i2c_start_read(unsigned char addr) {
33 return i2c_master_start((addr << 1) | I2C_READ);
34}
35
36static inline unsigned char i2c_start_write(unsigned char addr) {
37 return i2c_master_start((addr << 1) | I2C_WRITE);
38}
39
40// from SSD1306 scrips
41extern unsigned char i2c_rep_start(unsigned char addr);
42extern void i2c_start_wait(unsigned char addr);
43extern unsigned char i2c_readAck(void);
44extern unsigned char i2c_readNak(void);
45extern unsigned char i2c_read(unsigned char ack);
46
47#define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak();
48
49#endif
diff --git a/keyboards/zinc/keymaps/default/config.h b/keyboards/zinc/keymaps/default/config.h
index 4dcb0724f..2185dc9eb 100644
--- a/keyboards/zinc/keymaps/default/config.h
+++ b/keyboards/zinc/keymaps/default/config.h
@@ -20,8 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20*/ 20*/
21 21
22#pragma once 22#pragma once
23// if you need more program area, try uncomment follow line
24#include "serial_config_simpleapi.h"
25 23
26// place overrides here 24// place overrides here
27// Selection of RGBLIGHT MODE to use. 25// Selection of RGBLIGHT MODE to use.
diff --git a/keyboards/zinc/keymaps/default/keymap.c b/keyboards/zinc/keymaps/default/keymap.c
index 0f08d21ee..cd1bf0328 100644
--- a/keyboards/zinc/keymaps/default/keymap.c
+++ b/keyboards/zinc/keymaps/default/keymap.c
@@ -139,7 +139,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { \
139 * |------+------+------+------+------+------| |------+------+------+------+------+------| 139 * |------+------+------+------+------+------| |------+------+------+------+------+------|
140 * | |RGB ON| HUE+ | SAT+ | VAL+ | Mac | | Win | - | = |Print |ScLock|Pause | 140 * | |RGB ON| HUE+ | SAT+ | VAL+ | Mac | | Win | - | = |Print |ScLock|Pause |
141 * |------+------+------+------+------+------| |------+------+------+------+------+------| 141 * |------+------+------+------+------+------| |------+------+------+------+------+------|
142 * | | MODE | HUE- | SAT- | VAL- | | | | | | | | | 142 * |MODE R| MODE | HUE- | SAT- | VAL- | | | | | | |PageUp| |
143 * |------+------+------+------+------+------| |------+------+------+------+------+------| 143 * |------+------+------+------+------+------| |------+------+------+------+------+------|
144 * | | | | EISU | EISU | EISU | | KANA | KANA | Home |PageDn|PageUp| End | 144 * | | | | EISU | EISU | EISU | | KANA | KANA | Home |PageDn|PageUp| End |
145 * `-----------------------------------------' `-----------------------------------------' 145 * `-----------------------------------------' `-----------------------------------------'
@@ -147,13 +147,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { \
147 [_ADJUST] = LAYOUT_ortho_4x12( \ 147 [_ADJUST] = LAYOUT_ortho_4x12( \
148 _______, RESET, RGBRST, _______, _______, _______, _______, QWERTY, COLEMAK, DVORAK, _______, KC_INS, \ 148 _______, RESET, RGBRST, _______, _______, _______, _______, QWERTY, COLEMAK, DVORAK, _______, KC_INS, \
149 _______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, AG_NORM, AG_SWAP, KC_MINS, KC_EQL, KC_PSCR, KC_SLCK, KC_PAUS,\ 149 _______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, AG_NORM, AG_SWAP, KC_MINS, KC_EQL, KC_PSCR, KC_SLCK, KC_PAUS,\
150 _______, RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, _______, _______, _______, _______, _______, _______, _______,\ 150 RGB_RMOD,RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, _______, _______, _______, _______, _______, KC_PGUP, _______,\
151 _______, _______, _______, EISU, EISU, EISU, KANA, KANA, KC_HOME, KC_PGDN, KC_PGUP, KC_END\ 151 _______, _______, _______, EISU, EISU, EISU, KANA, KANA, KANA, KC_HOME, KC_PGDN, KC_END\
152 ) 152 )
153}; 153};
154 154
155// define variables for reactive RGB 155// define variables for reactive RGB
156bool TOG_STATUS = false; 156bool TOG_STATUS = false;
157 157
158// Setting ADJUST layer RGB back to default 158// Setting ADJUST layer RGB back to default
159void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) { 159void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
@@ -211,7 +211,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
211 } 211 }
212 return false; 212 return false;
213 break; 213 break;
214 214
215 case RAISE: 215 case RAISE:
216 if (record->event.pressed) { 216 if (record->event.pressed) {
217 //not sure how to have keyboard check mode and set it to a variable, so my work around 217 //not sure how to have keyboard check mode and set it to a variable, so my work around
@@ -244,16 +244,28 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
244 } 244 }
245 return false; 245 return false;
246 break; 246 break;
247
247 //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released 248 //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released
249 case RGB_RMOD:
250 #if defined(RGBLIGHT_ENABLE)
251 if (record->event.pressed) {
252 rgblight_mode_noeeprom(RGB_current_config.mode);
253 rgblight_step_reverse();
254 RGB_current_config.mode = rgblight_config.mode;
255 }
256 return false;
257 #endif
258 break;
259
248 case RGB_MOD: 260 case RGB_MOD:
249 #ifdef RGBLIGHT_ENABLE 261 #if defined(RGBLIGHT_ENABLE)
250 if (record->event.pressed) { 262 if (record->event.pressed) {
251 rgblight_mode_noeeprom(RGB_current_config.mode); 263 rgblight_mode_noeeprom(RGB_current_config.mode);
252 rgblight_step(); 264 rgblight_step();
253 RGB_current_config.mode = rgblight_config.mode; 265 RGB_current_config.mode = rgblight_config.mode;
254 } 266 }
255 #endif
256 return false; 267 return false;
268 #endif
257 break; 269 break;
258 270
259 case EISU: 271 case EISU:
diff --git a/keyboards/zinc/keymaps/default/readme_en.md b/keyboards/zinc/keymaps/default/readme_en.md
new file mode 100644
index 000000000..6447e96ed
--- /dev/null
+++ b/keyboards/zinc/keymaps/default/readme_en.md
@@ -0,0 +1,131 @@
1# The Default Zinc Layout
2## layout
3
4### Qwerty
5
6```
7 ,-----------------------------------------. ,-----------------------------------------.
8 | Tab | Q | W | E | R | T | | Y | U | I | O | P | Bksp |
9 |------+------+------+------+------+------| |------+------+------+------+------+------|
10 | Ctrl | A | S | D | F | G | | H | J | K | L | ; | ' |
11 |------+------+------+------+------+------| |------+------+------+------+------+------|
12 | Shift| Z | X | C | V | B | | N | M | , | . | / |Enter |
13 |------+------+------+------+------+------| |------+------+------+------+------+------|
14 | Esc | Fn | Alt | Win |Lower |Space | | Space| Raise| Left | Down | Up | Right|
15 `------------------------------------------ ------------------------------------------'
16```
17
18### Colemak
19
20```
21 ,-----------------------------------------. ,-----------------------------------------.
22 | Tab | Q | W | F | P | G | | J | L | U | Y | ; | Bksp |
23 |------+------+------+------+------+------| |------+------+------+------+------+------|
24 | Ctrl | A | R | S | T | D | | H | N | E | I | O | ' |
25 |------+------+------+------+------+------| |------+------+------+------+------+------|
26 | Shift| Z | X | C | V | B | | K | M | , | . | / |Enter |
27 |------+------+------+------+------+------| |------+------+------+------+------+------|
28 | Esc |ADJUST| Alt | Win |LOWER |Space | | Space| RAISE| Left | Down | Up | Right|
29 `------------------------------------------ ------------------------------------------'
30```
31
32### Dvorak
33
34```
35 ,-----------------------------------------. ,-----------------------------------------.
36 | Tab | ' | , | . | P | Y | | F | G | C | R | L | Del |
37 |------+------+------+------+------+------| |------+------+------+------+------+------|
38 | Ctrl | A | O | E | U | I | | D | H | T | N | S | / |
39 |------+------+------+------+------+------| |------+------+------+------+------+------|
40 | Shift| ; | Q | J | K | X | | B | M | W | V | Z |Enter |
41 |------+------+------+------+------+------| |------+------+------+------+------+------|
42 | Esc |ADJUST| Alt | Win |LOWER |Space | | Space| RAISE| Left | Down | Up | Right|
43 `-----------------------------------------' `-----------------------------------------'
44```
45
46### Lower
47```
48 ,-----------------------------------------. ,-----------------------------------------.
49 | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | |
50 |------+------+------+------+------+------| |------+------+------+------+------+------|
51 | | | | | | | | - | _ | + | { | } | | |
52 |------+------+------+------+------+------| |------+------+------+------+------+------|
53 | | | | | | | | | | | Home | End | |
54 |------+------+------+------+------+------| |------+------+------+------+------+------|
55 | | | | | | | | | | Next | Vol- | Vol+ | Play |
56 `-----------------------------------------' `-----------------------------------------'
57```
58
59### RAISE
60```
61 ,-----------------------------------------. ,-----------------------------------------.
62 | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
63 |------+------+------+------+------+------| |------+------+------+------+------+------|
64 | | F1 | F2 | F3 | F4 | F5 | | F6 | - | = | [ | ] | \ |
65 |------+------+------+------+------+------| |------+------+------+------+------+------|
66 | | F7 | F8 | F9 | F10 | F11 | | F12 | | | | |
67 |------+------+------+------+------+------| |------+------+------+------+------+------|
68 | | | | | | | | | | Next | Vol- | Vol+ | Play |
69 `-----------------------------------------' `-----------------------------------------'
70```
71
72### Adjust (Lower + Raise)
73```
74 ,-----------------------------------------. ,-----------------------------------------.
75 | | Reset|RGBRST|Aud on|Audoff| | | |Qwerty|Colemk|Dvorak| | Ins |
76 |------+------+------+------+------+------| |------+------+------+------+------+------|
77 | |RGB ON| HUE+ | SAT+ | VAL+ | Mac | | Win | - | = |Print |ScLock|Pause |
78 |------+------+------+------+------+------| |------+------+------+------+------+------|
79 |MODE R|RGBMOD| HUE- | SAT- | VAL- | | | | | | |PageUp| |
80 |------+------+------+------+------+------| |------+------+------+------+------+------|
81 | | | | EISU | EISU | EISU | | KANA | KANA | KANA | Home |PageDn| End |
82 `-----------------------------------------' `-----------------------------------------'
83```
84
85## Compile
86
87go to qmk top directory.
88
89```
90$ cd qmk_firmware
91```
92make with `zinc:<keymap_name>`
93
94```
95$ make zinc:default
96```
97
98To make and flash with `:flash`
99
100```
101$ make zinc:default:flash
102```
103
104
105## Customize
106
107You can customize from the command line.
108
109```
110# Zinc keyboard 'default' keymap: convenient command line option
111make ZINC=<options> zinc:defualt
112# option= back | under | both | cont | na | ios
113# ex.
114# make ZINC=under zinc:defualt
115# make ZINC=under,ios zinc:defualt
116# make ZINC=back zinc:default
117# make ZINC=back,na zinc:default
118# make ZINC=back,ios zinc:default
119```
120
121Or edit `qmk_firmware/keyboards/zinc/rev1/keymaps/~/rules.mk` directly.
122
123```
124# Zinc keyboard customize
125LED_BACK_ENABLE = no # LED backlight (Enable SK6812mini backlight)
126LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight)
127LED_BOTH_ENABLE = no # LED backlight and underglow
128LED_RGB_CONT = no # LED continuous backlight or/and underglow between left Zinc and right Zinc
129LED_ANIMATIONS = yes # LED animations
130IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone)
131```
diff --git a/keyboards/zinc/keymaps/default/readme_jp.md b/keyboards/zinc/keymaps/default/readme_jp.md
index dfedb37c1..8132f5036 100644
--- a/keyboards/zinc/keymaps/default/readme_jp.md
+++ b/keyboards/zinc/keymaps/default/readme_jp.md
@@ -43,6 +43,44 @@
43 `-----------------------------------------' `-----------------------------------------' 43 `-----------------------------------------' `-----------------------------------------'
44``` 44```
45 45
46 ### Lower
47```
48 ,-----------------------------------------. ,-----------------------------------------.
49 | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | |
50 |------+------+------+------+------+------| |------+------+------+------+------+------|
51 | | | | | | | | - | _ | + | { | } | | |
52 |------+------+------+------+------+------| |------+------+------+------+------+------|
53 | | | | | | | | | | | Home | End | |
54 |------+------+------+------+------+------| |------+------+------+------+------+------|
55 | | | | | | | | | | Next | Vol- | Vol+ | Play |
56 `-----------------------------------------' `-----------------------------------------'
57```
58
59### RAISE
60```
61 ,-----------------------------------------. ,-----------------------------------------.
62 | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
63 |------+------+------+------+------+------| |------+------+------+------+------+------|
64 | | F1 | F2 | F3 | F4 | F5 | | F6 | - | = | [ | ] | \ |
65 |------+------+------+------+------+------| |------+------+------+------+------+------|
66 | | F7 | F8 | F9 | F10 | F11 | | F12 | | | | |
67 |------+------+------+------+------+------| |------+------+------+------+------+------|
68 | | | | | | | | | | Next | Vol- | Vol+ | Play |
69 `-----------------------------------------' `-----------------------------------------'
70```
71
72### Adjust (Lower + Raise)
73```
74 ,-----------------------------------------. ,-----------------------------------------.
75 | | Reset|RGBRST|Aud on|Audoff| | | |Qwerty|Colemk|Dvorak| | Ins |
76 |------+------+------+------+------+------| |------+------+------+------+------+------|
77 | |RGB ON| HUE+ | SAT+ | VAL+ | Mac | | Win | - | = |Print |ScLock|Pause |
78 |------+------+------+------+------+------| |------+------+------+------+------+------|
79 |MODE R|RGBMOD| HUE- | SAT- | VAL- | | | | | | |PageUp| |
80 |------+------+------+------+------+------| |------+------+------+------+------+------|
81 | | | | EISU | EISU | EISU | | KANA | KANA | KANA | Home |PageDn| End |
82 `-----------------------------------------' `-----------------------------------------'
83```
46 84
47## コンパイルの仕方 85## コンパイルの仕方
48 86
@@ -76,7 +114,7 @@ $ make zinc:default:clean
76``` 114```
77# Zinc keyboard 'default' keymap: convenient command line option 115# Zinc keyboard 'default' keymap: convenient command line option
78make ZINC=<options> zinc:defualt 116make ZINC=<options> zinc:defualt
79# option= back | under | na | ios 117# option= back | under | both | cont | na | ios
80# ex. 118# ex.
81# make ZINC=under zinc:defualt 119# make ZINC=under zinc:defualt
82# make ZINC=under,ios zinc:defualt 120# make ZINC=under,ios zinc:defualt
@@ -85,16 +123,16 @@ make ZINC=<options> zinc:defualt
85# make ZINC=back,ios zinc:default 123# make ZINC=back,ios zinc:default
86``` 124```
87 125
88あるいは`qmk_firmware/keyboards/zinc/rev1/keymaps/default/rules.mk` の以下の部分を直接編集して機能を有効化してください。 126あるいは`qmk_firmware/keyboards/zinc/rev1/keymaps/~/rules.mk` の以下の部分を直接編集して機能を有効化してください。
89 127
90``` 128```
91# Zinc keyboard customize 129# Zinc keyboard customize
92LED_BACK_ENABLE = no # LED backlight (Enable SK6812mini backlight) 130LED_BACK_ENABLE = no # LED backlight (Enable SK6812mini backlight)
93LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight) 131LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight)
132LED_BOTH_ENABLE = no # LED backlight and underglow
133LED_RGB_CONT = no # LED continuous backlight or/and underglow between left Zinc and right Zinc
94LED_ANIMATIONS = yes # LED animations 134LED_ANIMATIONS = yes # LED animations
95IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) 135IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone)
96
97
98``` 136```
99 137
100## RGB backlight を有効にする 138## RGB backlight を有効にする
@@ -120,4 +158,4 @@ RBG Underglow や RGBバックライトの輝度を抑えて、iPad, iPhone に
120 158
121``` 159```
122IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) 160IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone)
123``` \ No newline at end of file 161```
diff --git a/keyboards/zinc/keymaps/default/rules.mk b/keyboards/zinc/keymaps/default/rules.mk
index c980f7d00..32e0f2161 100644
--- a/keyboards/zinc/keymaps/default/rules.mk
+++ b/keyboards/zinc/keymaps/default/rules.mk
@@ -20,6 +20,9 @@ define ZINC_CUSTOMISE_MSG
20 $(info Zinc customize) 20 $(info Zinc customize)
21 $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE)) 21 $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE))
22 $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE)) 22 $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE))
23 $(info - LED_BOTH_ENABLE=$(LED_BOTH_ENABLE))
24 $(info - LED_RGB_CONT=$(LED_RGB_CONT))
25 $(info - RGB_MATRIX=$(RGB_MATRIX))
23 $(info - LED_ANIMATION=$(LED_ANIMATIONS)) 26 $(info - LED_ANIMATION=$(LED_ANIMATIONS))
24 $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE)) 27 $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE))
25endef 28endef
@@ -27,6 +30,10 @@ endef
27# Zinc keyboard customize 30# Zinc keyboard customize
28LED_BACK_ENABLE = no # LED backlight (Enable SK6812mini backlight) 31LED_BACK_ENABLE = no # LED backlight (Enable SK6812mini backlight)
29LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight) 32LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight)
33LED_BOTH_ENABLE = no # LED backlight and underglow
34LED_RGB_CONT = no # LED continuous backlight or/and underglow between left Zinc and right Zinc
35RGB_MATRIX = no # RGB LED Matrix
36RGB_MATRIX_SPLIT_RIGHT = no # RGB Matrix for RIGHT Hand
30LED_ANIMATIONS = yes # LED animations 37LED_ANIMATIONS = yes # LED animations
31IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) 38IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone)
32Link_Time_Optimization = no # if firmware size over limit, try this option 39Link_Time_Optimization = no # if firmware size over limit, try this option
@@ -36,7 +43,7 @@ Link_Time_Optimization = no # if firmware size over limit, try this option
36 43
37### Zinc keyboard 'default' keymap: convenient command line option 44### Zinc keyboard 'default' keymap: convenient command line option
38## make ZINC=<options> zinc:defualt 45## make ZINC=<options> zinc:defualt
39## option= back | under | na | ios 46## option= back | under | both | cont | matrix | na | ios
40## ex. 47## ex.
41## make ZINC=under zinc:defualt 48## make ZINC=under zinc:defualt
42## make ZINC=under,ios zinc:defualt 49## make ZINC=under,ios zinc:defualt
@@ -47,9 +54,22 @@ Link_Time_Optimization = no # if firmware size over limit, try this option
47ifneq ($(strip $(ZINC)),) 54ifneq ($(strip $(ZINC)),)
48 ifeq ($(findstring back,$(ZINC)), back) 55 ifeq ($(findstring back,$(ZINC)), back)
49 LED_BACK_ENABLE = yes 56 LED_BACK_ENABLE = yes
50 else ifeq ($(findstring under,$(ZINC)), under) 57 endif
58 ifeq ($(findstring under,$(ZINC)), under)
51 LED_UNDERGLOW_ENABLE = yes 59 LED_UNDERGLOW_ENABLE = yes
52 endif 60 endif
61 ifeq ($(findstring both,$(ZINC)), both)
62 LED_BOTH_ENABLE = yes
63 endif
64 ifeq ($(findstring cont,$(ZINC)), cont)
65 LED_RGB_CONT = yes
66 endif
67 ifeq ($(findstring matrix,$(ZINC)), matrix)
68 RGB_MATRIX = yes
69 endif
70 ifeq ($(findstring right,$(ZINC)), right)
71 RGB_MATRIX_SPLIT_RIGHT = yes
72 endif
53 ifeq ($(findstring na,$(ZINC)), na) 73 ifeq ($(findstring na,$(ZINC)), na)
54 LED_ANIMATIONS = no 74 LED_ANIMATIONS = no
55 endif 75 endif
@@ -62,10 +82,11 @@ endif
62 82
63ifeq ($(strip $(LED_BACK_ENABLE)), yes) 83ifeq ($(strip $(LED_BACK_ENABLE)), yes)
64 RGBLIGHT_ENABLE = yes 84 RGBLIGHT_ENABLE = yes
65 OPT_DEFS += -DRGBLED_BACK
66 ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) 85 ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes)
67 $(eval $(call ZINC_CUSTOMISE_MSG)) 86 OPT_DEFS += -DRGBLED_BOTH
68 $(error LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE both 'yes') 87 $(info LED_BOTH_ENABLE option is enabled instead of LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE)
88 else
89 OPT_DEFS += -DRGBLED_BACK
69 endif 90 endif
70else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) 91else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes)
71 RGBLIGHT_ENABLE = yes 92 RGBLIGHT_ENABLE = yes
@@ -73,18 +94,36 @@ else
73 RGBLIGHT_ENABLE = no 94 RGBLIGHT_ENABLE = no
74endif 95endif
75 96
97ifeq ($(strip $(LED_BOTH_ENABLE)), yes)
98 RGBLIGHT_ENABLE = yes
99 OPT_DEFS += -DRGBLED_BOTH
100endif
101
102ifeq ($(strip $(LED_RGB_CONT)), yes)
103 OPT_DEFS += -DRGBLED_CONT
104endif
105
106ifeq ($(strip $(RGB_MATRIX)), yes)
107 RGBLIGHT_ENABLE = no
108 RGB_MATRIX_ENABLE = WS2812
109endif
110
76ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) 111ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes)
77 OPT_DEFS += -DIOS_DEVICE_ENABLE 112 OPT_DEFS += -DIOS_DEVICE_ENABLE
78endif 113endif
79 114
80ifeq ($(strip $(LED_ANIMATIONS)), yes) 115ifeq ($(strip $(LED_ANIMATIONS)), yes)
81# OPT_DEFS += -DRGBLIGHT_ANIMATIONS 116# OPT_DEFS += -DRGBLIGHT_ANIMATIONS
82 OPT_DEFS += -DLED_ANIMATIONS 117 OPT_DEFS += -DLED_ANIMATIONS
118
119endif
83 120
121ifeq ($(strip $(RGB_MATRIX_SPLIT_RIGHT)), yes)
122 OPT_DEFS += -DRGB_MATRIX_SPLIT_RIGHT
84endif 123endif
85 124
86ifeq ($(strip $(Link_Time_Optimization)),yes) 125ifeq ($(strip $(Link_Time_Optimization)),yes)
87 EXTRAFLAGS += -flto -DUSE_Link_Time_Optimization 126 EXTRAFLAGS += -flto -DUSE_Link_Time_Optimization
88endif 127endif
89 128
90# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE 129# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
diff --git a/keyboards/zinc/keymaps/ginjake/config.h b/keyboards/zinc/keymaps/ginjake/config.h
index 4dcb0724f..2185dc9eb 100644
--- a/keyboards/zinc/keymaps/ginjake/config.h
+++ b/keyboards/zinc/keymaps/ginjake/config.h
@@ -20,8 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20*/ 20*/
21 21
22#pragma once 22#pragma once
23// if you need more program area, try uncomment follow line
24#include "serial_config_simpleapi.h"
25 23
26// place overrides here 24// place overrides here
27// Selection of RGBLIGHT MODE to use. 25// Selection of RGBLIGHT MODE to use.
diff --git a/keyboards/zinc/keymaps/ginjake/rules.mk b/keyboards/zinc/keymaps/ginjake/rules.mk
index 2dcefc001..2cb59fe8b 100644
--- a/keyboards/zinc/keymaps/ginjake/rules.mk
+++ b/keyboards/zinc/keymaps/ginjake/rules.mk
@@ -1,12 +1,11 @@
1
2# Build Options 1# Build Options
3# change to "no" to disable the options, or define them in the Makefile in 2# change to "no" to disable the options, or define them in the Makefile in
4# the appropriate keymap folder that will get included automatically 3# the appropriate keymap folder that will get included automatically
5# 4#
6BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) 5BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
7MOUSEKEY_ENABLE = no # Mouse keys(+4700) 6MOUSEKEY_ENABLE = no # Mouse keys
8EXTRAKEY_ENABLE = yes # Audio control and System control(+450) 7EXTRAKEY_ENABLE = yes # Audio control and System control
9CONSOLE_ENABLE = no # Console for debug(+400) 8CONSOLE_ENABLE = no # Console for debug
10COMMAND_ENABLE = no # Commands for debug and configuration 9COMMAND_ENABLE = no # Commands for debug and configuration
11NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work 10NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
12BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality 11BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
@@ -21,6 +20,8 @@ define ZINC_CUSTOMISE_MSG
21 $(info Zinc customize) 20 $(info Zinc customize)
22 $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE)) 21 $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE))
23 $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE)) 22 $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE))
23 $(info - LED_BOTH_ENABLE=$(LED_BOTH_ENABLE))
24 $(info - LED_RGB_CONT=$(LED_RGB_CONT))
24 $(info - LED_ANIMATION=$(LED_ANIMATIONS)) 25 $(info - LED_ANIMATION=$(LED_ANIMATIONS))
25 $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE)) 26 $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE))
26endef 27endef
@@ -28,6 +29,8 @@ endef
28# Zinc keyboard customize 29# Zinc keyboard customize
29LED_BACK_ENABLE = no # LED backlight (Enable SK6812mini backlight) 30LED_BACK_ENABLE = no # LED backlight (Enable SK6812mini backlight)
30LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight) 31LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight)
32LED_BOTH_ENABLE = no # LED backlight and underglow
33LED_RGB_CONT = no # LED continuous backlight or/and underglow between left Zinc and right Zinc
31LED_ANIMATIONS = yes # LED animations 34LED_ANIMATIONS = yes # LED animations
32IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) 35IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone)
33Link_Time_Optimization = no # if firmware size over limit, try this option 36Link_Time_Optimization = no # if firmware size over limit, try this option
@@ -37,7 +40,7 @@ Link_Time_Optimization = no # if firmware size over limit, try this option
37 40
38### Zinc keyboard 'default' keymap: convenient command line option 41### Zinc keyboard 'default' keymap: convenient command line option
39## make ZINC=<options> zinc:defualt 42## make ZINC=<options> zinc:defualt
40## option= back | under | na | ios 43## option= back | under | both | cont | na | ios
41## ex. 44## ex.
42## make ZINC=under zinc:defualt 45## make ZINC=under zinc:defualt
43## make ZINC=under,ios zinc:defualt 46## make ZINC=under,ios zinc:defualt
@@ -48,9 +51,16 @@ Link_Time_Optimization = no # if firmware size over limit, try this option
48ifneq ($(strip $(ZINC)),) 51ifneq ($(strip $(ZINC)),)
49 ifeq ($(findstring back,$(ZINC)), back) 52 ifeq ($(findstring back,$(ZINC)), back)
50 LED_BACK_ENABLE = yes 53 LED_BACK_ENABLE = yes
51 else ifeq ($(findstring under,$(ZINC)), under) 54 endif
55 ifeq ($(findstring under,$(ZINC)), under)
52 LED_UNDERGLOW_ENABLE = yes 56 LED_UNDERGLOW_ENABLE = yes
53 endif 57 endif
58 ifeq ($(findstring both,$(ZINC)), both)
59 LED_BOTH_ENABLE = yes
60 endif
61 ifeq ($(findstring cont,$(ZINC)), cont)
62 LED_RGB_CONT = yes
63 endif
54 ifeq ($(findstring na,$(ZINC)), na) 64 ifeq ($(findstring na,$(ZINC)), na)
55 LED_ANIMATIONS = no 65 LED_ANIMATIONS = no
56 endif 66 endif
@@ -63,10 +73,11 @@ endif
63 73
64ifeq ($(strip $(LED_BACK_ENABLE)), yes) 74ifeq ($(strip $(LED_BACK_ENABLE)), yes)
65 RGBLIGHT_ENABLE = yes 75 RGBLIGHT_ENABLE = yes
66 OPT_DEFS += -DRGBLED_BACK
67 ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) 76 ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes)
68 $(eval $(call ZINC_CUSTOMISE_MSG)) 77 OPT_DEFS += -DRGBLED_BOTH
69 $(error LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE both 'yes') 78 $(info LED_BOTH_ENABLE option is enabled instead of LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE)
79 else
80 OPT_DEFS += -DRGBLED_BACK
70 endif 81 endif
71else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) 82else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes)
72 RGBLIGHT_ENABLE = yes 83 RGBLIGHT_ENABLE = yes
@@ -74,18 +85,27 @@ else
74 RGBLIGHT_ENABLE = no 85 RGBLIGHT_ENABLE = no
75endif 86endif
76 87
88ifeq ($(strip $(LED_BOTH_ENABLE)), yes)
89 RGBLIGHT_ENABLE = yes
90 OPT_DEFS += -DRGBLED_BOTH
91endif
92
93ifeq ($(strip $(LED_RGB_CONT)), yes)
94 OPT_DEFS += -DRGBLED_CONT
95endif
96
77ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) 97ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes)
78 OPT_DEFS += -DIOS_DEVICE_ENABLE 98 OPT_DEFS += -DIOS_DEVICE_ENABLE
79endif 99endif
80 100
81ifeq ($(strip $(LED_ANIMATIONS)), yes) 101ifeq ($(strip $(LED_ANIMATIONS)), yes)
82# OPT_DEFS += -DRGBLIGHT_ANIMATIONS 102# OPT_DEFS += -DRGBLIGHT_ANIMATIONS
83 OPT_DEFS += -DLED_ANIMATIONS 103 OPT_DEFS += -DLED_ANIMATIONS
84 104
85endif 105endif
86 106
87ifeq ($(strip $(Link_Time_Optimization)),yes) 107ifeq ($(strip $(Link_Time_Optimization)),yes)
88 EXTRAFLAGS += -flto -DUSE_Link_Time_Optimization 108 EXTRAFLAGS += -flto -DUSE_Link_Time_Optimization
89endif 109endif
90 110
91# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE 111# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
diff --git a/keyboards/zinc/keymaps/monks/config.h b/keyboards/zinc/keymaps/monks/config.h
index 4dcb0724f..2185dc9eb 100644
--- a/keyboards/zinc/keymaps/monks/config.h
+++ b/keyboards/zinc/keymaps/monks/config.h
@@ -20,8 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20*/ 20*/
21 21
22#pragma once 22#pragma once
23// if you need more program area, try uncomment follow line
24#include "serial_config_simpleapi.h"
25 23
26// place overrides here 24// place overrides here
27// Selection of RGBLIGHT MODE to use. 25// Selection of RGBLIGHT MODE to use.
diff --git a/keyboards/zinc/keymaps/monks/keymap.c b/keyboards/zinc/keymaps/monks/keymap.c
index 5fd7c6aa8..a30e8ac5f 100644
--- a/keyboards/zinc/keymaps/monks/keymap.c
+++ b/keyboards/zinc/keymaps/monks/keymap.c
@@ -119,6 +119,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { \
119// define variables for reactive RGB 119// define variables for reactive RGB
120bool TOG_STATUS = false; 120bool TOG_STATUS = false;
121 121
122
122// Setting ADJUST layer RGB back to default 123// Setting ADJUST layer RGB back to default
123void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) { 124void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
124 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) { 125 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
@@ -163,7 +164,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
163 } 164 }
164 return false; 165 return false;
165 break; 166 break;
166 167
167 case RAISE: 168 case RAISE:
168 if (record->event.pressed) { 169 if (record->event.pressed) {
169 //not sure how to have keyboard check mode and set it to a variable, so my work around 170 //not sure how to have keyboard check mode and set it to a variable, so my work around
diff --git a/keyboards/zinc/keymaps/monks/readme_jp.md b/keyboards/zinc/keymaps/monks/readme_jp.md
index f1495af4c..e518eb769 100644
--- a/keyboards/zinc/keymaps/monks/readme_jp.md
+++ b/keyboards/zinc/keymaps/monks/readme_jp.md
@@ -100,4 +100,4 @@ RBG Underglow や RGBバックライトの輝度を抑えて、iPad, iPhone に
100 100
101``` 101```
102IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) 102IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone)
103``` \ No newline at end of file 103```
diff --git a/keyboards/zinc/keymaps/monks/rules.mk b/keyboards/zinc/keymaps/monks/rules.mk
index eeabc004c..c1b98dead 100644
--- a/keyboards/zinc/keymaps/monks/rules.mk
+++ b/keyboards/zinc/keymaps/monks/rules.mk
@@ -1,12 +1,11 @@
1
2# Build Options 1# Build Options
3# change to "no" to disable the options, or define them in the Makefile in 2# change to "no" to disable the options, or define them in the Makefile in
4# the appropriate keymap folder that will get included automatically 3# the appropriate keymap folder that will get included automatically
5# 4#
6BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) 5BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
7MOUSEKEY_ENABLE = no # Mouse keys(+4700) 6MOUSEKEY_ENABLE = no # Mouse keys
8EXTRAKEY_ENABLE = yes # Audio control and System control(+450) 7EXTRAKEY_ENABLE = yes # Audio control and System control
9CONSOLE_ENABLE = no # Console for debug(+400) 8CONSOLE_ENABLE = no # Console for debug
10COMMAND_ENABLE = no # Commands for debug and configuration 9COMMAND_ENABLE = no # Commands for debug and configuration
11NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work 10NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
12BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality 11BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
@@ -21,6 +20,8 @@ define ZINC_CUSTOMISE_MSG
21 $(info Zinc customize) 20 $(info Zinc customize)
22 $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE)) 21 $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE))
23 $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE)) 22 $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE))
23 $(info - LED_BOTH_ENABLE=$(LED_BOTH_ENABLE))
24 $(info - LED_RGB_CONT=$(LED_RGB_CONT))
24 $(info - LED_ANIMATION=$(LED_ANIMATIONS)) 25 $(info - LED_ANIMATION=$(LED_ANIMATIONS))
25 $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE)) 26 $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE))
26endef 27endef
@@ -28,6 +29,8 @@ endef
28# Zinc keyboard customize 29# Zinc keyboard customize
29LED_BACK_ENABLE = no # LED backlight (Enable SK6812mini backlight) 30LED_BACK_ENABLE = no # LED backlight (Enable SK6812mini backlight)
30LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight) 31LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight)
32LED_BOTH_ENABLE = no # LED backlight and underglow
33LED_RGB_CONT = no # LED continuous backlight or/and underglow between left Zinc and right Zinc
31LED_ANIMATIONS = yes # LED animations 34LED_ANIMATIONS = yes # LED animations
32IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) 35IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone)
33Link_Time_Optimization = no # if firmware size over limit, try this option 36Link_Time_Optimization = no # if firmware size over limit, try this option
@@ -37,7 +40,7 @@ Link_Time_Optimization = no # if firmware size over limit, try this option
37 40
38### Zinc keyboard 'default' keymap: convenient command line option 41### Zinc keyboard 'default' keymap: convenient command line option
39## make ZINC=<options> zinc:defualt 42## make ZINC=<options> zinc:defualt
40## option= back | under | na | ios 43## option= back | under | both | cont | na | ios
41## ex. 44## ex.
42## make ZINC=under zinc:defualt 45## make ZINC=under zinc:defualt
43## make ZINC=under,ios zinc:defualt 46## make ZINC=under,ios zinc:defualt
@@ -48,9 +51,16 @@ Link_Time_Optimization = no # if firmware size over limit, try this option
48ifneq ($(strip $(ZINC)),) 51ifneq ($(strip $(ZINC)),)
49 ifeq ($(findstring back,$(ZINC)), back) 52 ifeq ($(findstring back,$(ZINC)), back)
50 LED_BACK_ENABLE = yes 53 LED_BACK_ENABLE = yes
51 else ifeq ($(findstring under,$(ZINC)), under) 54 endif
55 ifeq ($(findstring under,$(ZINC)), under)
52 LED_UNDERGLOW_ENABLE = yes 56 LED_UNDERGLOW_ENABLE = yes
53 endif 57 endif
58 ifeq ($(findstring both,$(ZINC)), both)
59 LED_BOTH_ENABLE = yes
60 endif
61 ifeq ($(findstring cont,$(ZINC)), cont)
62 LED_RGB_CONT = yes
63 endif
54 ifeq ($(findstring na,$(ZINC)), na) 64 ifeq ($(findstring na,$(ZINC)), na)
55 LED_ANIMATIONS = no 65 LED_ANIMATIONS = no
56 endif 66 endif
@@ -63,10 +73,11 @@ endif
63 73
64ifeq ($(strip $(LED_BACK_ENABLE)), yes) 74ifeq ($(strip $(LED_BACK_ENABLE)), yes)
65 RGBLIGHT_ENABLE = yes 75 RGBLIGHT_ENABLE = yes
66 OPT_DEFS += -DRGBLED_BACK
67 ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) 76 ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes)
68 $(eval $(call ZINC_CUSTOMISE_MSG)) 77 OPT_DEFS += -DRGBLED_BOTH
69 $(error LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE both 'yes') 78 $(info LED_BOTH_ENABLE option is enabled instead of LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE)
79 else
80 OPT_DEFS += -DRGBLED_BACK
70 endif 81 endif
71else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) 82else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes)
72 RGBLIGHT_ENABLE = yes 83 RGBLIGHT_ENABLE = yes
@@ -74,17 +85,27 @@ else
74 RGBLIGHT_ENABLE = no 85 RGBLIGHT_ENABLE = no
75endif 86endif
76 87
88ifeq ($(strip $(LED_BOTH_ENABLE)), yes)
89 RGBLIGHT_ENABLE = yes
90 OPT_DEFS += -DRGBLED_BOTH
91endif
92
93ifeq ($(strip $(LED_RGB_CONT)), yes)
94 OPT_DEFS += -DRGBLED_CONT
95endif
96
77ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) 97ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes)
78 OPT_DEFS += -DIOS_DEVICE_ENABLE 98 OPT_DEFS += -DIOS_DEVICE_ENABLE
79endif 99endif
80 100
81ifeq ($(strip $(LED_ANIMATIONS)), yes) 101ifeq ($(strip $(LED_ANIMATIONS)), yes)
82# OPT_DEFS += -DRGBLIGHT_ANIMATIONS 102# OPT_DEFS += -DRGBLIGHT_ANIMATIONS
83 OPT_DEFS += -DLED_ANIMATIONS 103 OPT_DEFS += -DLED_ANIMATIONS
104
84endif 105endif
85 106
86ifeq ($(strip $(Link_Time_Optimization)),yes) 107ifeq ($(strip $(Link_Time_Optimization)),yes)
87 EXTRAFLAGS += -flto -DUSE_Link_Time_Optimization 108 EXTRAFLAGS += -flto -DUSE_Link_Time_Optimization
88endif 109endif
89 110
90# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE 111# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
@@ -94,4 +115,3 @@ SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
94# $(info -- RGBLIGHT_ENABLE=$(RGBLIGHT_ENABLE)) 115# $(info -- RGBLIGHT_ENABLE=$(RGBLIGHT_ENABLE))
95# $(info -- OPT_DEFS=$(OPT_DEFS)) 116# $(info -- OPT_DEFS=$(OPT_DEFS))
96# $(info ) 117# $(info )
97
diff --git a/keyboards/zinc/keymaps/toshi0383/config.h b/keyboards/zinc/keymaps/toshi0383/config.h
index 33108a29e..0d53d4424 100644
--- a/keyboards/zinc/keymaps/toshi0383/config.h
+++ b/keyboards/zinc/keymaps/toshi0383/config.h
@@ -21,8 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
21*/ 21*/
22 22
23#pragma once 23#pragma once
24// if you need more program area, try uncomment follow line
25#include "serial_config_simpleapi.h"
26 24
27// place overrides here 25// place overrides here
28// Selection of RGBLIGHT MODE to use. 26// Selection of RGBLIGHT MODE to use.
diff --git a/keyboards/zinc/keymaps/toshi0383/rules.mk b/keyboards/zinc/keymaps/toshi0383/rules.mk
index dca9aa7ff..26ac02f3a 100644
--- a/keyboards/zinc/keymaps/toshi0383/rules.mk
+++ b/keyboards/zinc/keymaps/toshi0383/rules.mk
@@ -1,11 +1,12 @@
1# Build Options 1# Build Options
2# change yes to no to disable 2# change to "no" to disable the options, or define them in the Makefile in
3# the appropriate keymap folder that will get included automatically
3# 4#
4BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration 5BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
5MOUSEKEY_ENABLE = no # Mouse keys 6MOUSEKEY_ENABLE = no # Mouse keys
6EXTRAKEY_ENABLE = yes # Audio control and System control 7EXTRAKEY_ENABLE = yes # Audio control and System control
7CONSOLE_ENABLE = no # Console for debug 8CONSOLE_ENABLE = no # Console for debug
8COMMAND_ENABLE = no # Commands for debug and configuration 9COMMAND_ENABLE = no # Commands for debug and configuration
9NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work 10NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
10BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality 11BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
11MIDI_ENABLE = no # MIDI controls 12MIDI_ENABLE = no # MIDI controls
@@ -19,6 +20,9 @@ define ZINC_CUSTOMISE_MSG
19 $(info Zinc customize) 20 $(info Zinc customize)
20 $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE)) 21 $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE))
21 $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE)) 22 $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE))
23 $(info - LED_BOTH_ENABLE=$(LED_BOTH_ENABLE))
24 $(info - LED_RGB_CONT=$(LED_RGB_CONT))
25 $(info - RGB_MATRIX=$(RGB_MATRIX))
22 $(info - LED_ANIMATION=$(LED_ANIMATIONS)) 26 $(info - LED_ANIMATION=$(LED_ANIMATIONS))
23 $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE)) 27 $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE))
24endef 28endef
@@ -26,6 +30,10 @@ endef
26# Zinc keyboard customize 30# Zinc keyboard customize
27LED_BACK_ENABLE = no # LED backlight (Enable SK6812mini backlight) 31LED_BACK_ENABLE = no # LED backlight (Enable SK6812mini backlight)
28LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight) 32LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight)
33LED_BOTH_ENABLE = no # LED backlight and underglow
34LED_RGB_CONT = no # LED continuous backlight or/and underglow between left Zinc and right Zinc
35RGB_MATRIX = no # RGB LED Matrix
36RGB_MATRIX_SPLIT_RIGHT = no # RGB Matrix for RIGHT Hand
29LED_ANIMATIONS = yes # LED animations 37LED_ANIMATIONS = yes # LED animations
30IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) 38IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone)
31Link_Time_Optimization = no # if firmware size over limit, try this option 39Link_Time_Optimization = no # if firmware size over limit, try this option
@@ -35,7 +43,7 @@ Link_Time_Optimization = no # if firmware size over limit, try this option
35 43
36### Zinc keyboard 'default' keymap: convenient command line option 44### Zinc keyboard 'default' keymap: convenient command line option
37## make ZINC=<options> zinc:defualt 45## make ZINC=<options> zinc:defualt
38## option= back | under | na | ios 46## option= back | under | both | cont | matrix | na | ios
39## ex. 47## ex.
40## make ZINC=under zinc:defualt 48## make ZINC=under zinc:defualt
41## make ZINC=under,ios zinc:defualt 49## make ZINC=under,ios zinc:defualt
@@ -46,9 +54,22 @@ Link_Time_Optimization = no # if firmware size over limit, try this option
46ifneq ($(strip $(ZINC)),) 54ifneq ($(strip $(ZINC)),)
47 ifeq ($(findstring back,$(ZINC)), back) 55 ifeq ($(findstring back,$(ZINC)), back)
48 LED_BACK_ENABLE = yes 56 LED_BACK_ENABLE = yes
49 else ifeq ($(findstring under,$(ZINC)), under) 57 endif
58 ifeq ($(findstring under,$(ZINC)), under)
50 LED_UNDERGLOW_ENABLE = yes 59 LED_UNDERGLOW_ENABLE = yes
51 endif 60 endif
61 ifeq ($(findstring both,$(ZINC)), both)
62 LED_BOTH_ENABLE = yes
63 endif
64 ifeq ($(findstring cont,$(ZINC)), cont)
65 LED_RGB_CONT = yes
66 endif
67 ifeq ($(findstring matrix,$(ZINC)), matrix)
68 RGB_MATRIX = yes
69 endif
70 ifeq ($(findstring right,$(ZINC)), right)
71 RGB_MATRIX_SPLIT_RIGHT = yes
72 endif
52 ifeq ($(findstring na,$(ZINC)), na) 73 ifeq ($(findstring na,$(ZINC)), na)
53 LED_ANIMATIONS = no 74 LED_ANIMATIONS = no
54 endif 75 endif
@@ -61,10 +82,11 @@ endif
61 82
62ifeq ($(strip $(LED_BACK_ENABLE)), yes) 83ifeq ($(strip $(LED_BACK_ENABLE)), yes)
63 RGBLIGHT_ENABLE = yes 84 RGBLIGHT_ENABLE = yes
64 OPT_DEFS += -DRGBLED_BACK
65 ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) 85 ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes)
66 $(eval $(call ZINC_CUSTOMISE_MSG)) 86 OPT_DEFS += -DRGBLED_BOTH
67 $(error LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE both 'yes') 87 $(info LED_BOTH_ENABLE option is enabled instead of LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE)
88 else
89 OPT_DEFS += -DRGBLED_BACK
68 endif 90 endif
69else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) 91else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes)
70 RGBLIGHT_ENABLE = yes 92 RGBLIGHT_ENABLE = yes
@@ -72,24 +94,43 @@ else
72 RGBLIGHT_ENABLE = no 94 RGBLIGHT_ENABLE = no
73endif 95endif
74 96
97ifeq ($(strip $(LED_BOTH_ENABLE)), yes)
98 RGBLIGHT_ENABLE = yes
99 OPT_DEFS += -DRGBLED_BOTH
100endif
101
102ifeq ($(strip $(LED_RGB_CONT)), yes)
103 OPT_DEFS += -DRGBLED_CONT
104endif
105
106ifeq ($(strip $(RGB_MATRIX)), yes)
107 RGBLIGHT_ENABLE = no
108 RGB_MATRIX_ENABLE = WS2812
109endif
110
75ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) 111ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes)
76 OPT_DEFS += -DIOS_DEVICE_ENABLE 112 OPT_DEFS += -DIOS_DEVICE_ENABLE
77endif 113endif
78 114
79ifeq ($(strip $(LED_ANIMATIONS)), yes) 115ifeq ($(strip $(LED_ANIMATIONS)), yes)
80# OPT_DEFS += -DRGBLIGHT_ANIMATIONS 116# OPT_DEFS += -DRGBLIGHT_ANIMATIONS
81 OPT_DEFS += -DLED_ANIMATIONS 117 OPT_DEFS += -DLED_ANIMATIONS
118
119endif
120
121ifeq ($(strip $(RGB_MATRIX_SPLIT_RIGHT)), yes)
122 OPT_DEFS += -DRGB_MATRIX_SPLIT_RIGHT
82endif 123endif
83 124
84ifeq ($(strip $(Link_Time_Optimization)),yes) 125ifeq ($(strip $(Link_Time_Optimization)),yes)
85 EXTRAFLAGS += -flto -DUSE_Link_Time_Optimization 126 EXTRAFLAGS += -flto -DUSE_Link_Time_Optimization
86endif 127endif
87 128
88# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE 129# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
89SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend 130SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
90 131
132
91# Uncomment these for debugging 133# Uncomment these for debugging
92# $(info -- RGBLIGHT_ENABLE=$(RGBLIGHT_ENABLE)) 134# $(info -- RGBLIGHT_ENABLE=$(RGBLIGHT_ENABLE))
93# $(info -- OPT_DEFS=$(OPT_DEFS)) 135# $(info -- OPT_DEFS=$(OPT_DEFS))
94# $(info ) 136# $(info )
95
diff --git a/keyboards/zinc/readme.md b/keyboards/zinc/readme.md
index 3b4ce105c..0e8d6cd65 100644
--- a/keyboards/zinc/readme.md
+++ b/keyboards/zinc/readme.md
@@ -5,9 +5,9 @@ Zinc
5 5
640% row-staggered split keyboard. 640% row-staggered split keyboard.
7 7
8Keyboard Maintainer: [monksoffunk](https://github.com/monksoffunk/) [@monksoffunkJP](https://twitter.com/monksoffunkJP) 8* Keyboard Maintainer: [monksoffunk](https://github.com/monksoffunk/) [@monksoffunkJP](https://twitter.com/monksoffunkJP)
9Hardware Supported: Zinc PCB 9* Hardware Supported: Zinc PCB
10Hardware Availability: (https://twitter.com/monksoffunkJP) 10* Hardware Availability: (https://twitter.com/monksoffunkJP)
11 11
12Make example for this keyboard (after setting up your build environment): 12Make example for this keyboard (after setting up your build environment):
13 13
diff --git a/keyboards/zinc/rev1/config.h b/keyboards/zinc/rev1/config.h
index 6713b3098..1eb63df5b 100644
--- a/keyboards/zinc/rev1/config.h
+++ b/keyboards/zinc/rev1/config.h
@@ -18,9 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18 18
19#pragma once 19#pragma once
20 20
21//#ifndef REV1_CONFIG_H
22//#define REV1_CONFIG_H
23
24/* USB Device descriptor parameter */ 21/* USB Device descriptor parameter */
25#define VENDOR_ID 0xFEED 22#define VENDOR_ID 0xFEED
26#define PRODUCT_ID 0x9991 23#define PRODUCT_ID 0x9991
@@ -33,9 +30,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
33#define TAPPING_TERM 100 30#define TAPPING_TERM 100
34 31
35/* Use I2C or Serial */ 32/* Use I2C or Serial */
36//#define USE_I2C
37#define USE_SERIAL 33#define USE_SERIAL
38//#define USE_MATRIX_I2C 34#define SOFT_SERIAL_PIN D2
39 35
40/* Select hand configuration */ 36/* Select hand configuration */
41#define MASTER_LEFT 37#define MASTER_LEFT
@@ -44,18 +40,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
44 40
45/* key matrix size */ 41/* key matrix size */
46// Rows are doubled-up 42// Rows are doubled-up
47 #define MATRIX_ROWS 8 43#define MATRIX_ROWS 8
48 #define MATRIX_ROW_PINS { F6, F7, B1, B3 } 44#define MATRIX_ROW_PINS { F6, F7, B1, B3 }
49 45
50// wiring of each half 46// wiring of each half
51#define MATRIX_COLS 6 47#define MATRIX_COLS 6
52#define MATRIX_COL_PINS { F4, D4, C6, D7, E6, B4 } 48#define MATRIX_COL_PINS { F4, D4, C6, D7, E6, B4 }
53 49
54/* define if matrix has ghost */ 50#define DIODE_DIRECTION COL2ROW
55//#define MATRIX_HAS_GHOST
56
57/* number of backlight levels */
58// #define BACKLIGHT_LEVELS 3
59 51
60/* Set 0 if debouncing isn't needed */ 52/* Set 0 if debouncing isn't needed */
61#define DEBOUNCE 5 53#define DEBOUNCE 5
@@ -67,25 +59,44 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
67 59
68/* ws2812 RGB LED */ 60/* ws2812 RGB LED */
69#define RGB_DI_PIN D3 61#define RGB_DI_PIN D3
70#define RGBLIGHT_TIMER
71//#define RGBLED_NUM 12 // Number of LEDs. see ./keymaps/default/config.h
72#define ws2812_PORTREG PORTD
73#define ws2812_DDRREG DDRD
74 62
75// RGB LED support 63// RGB LED support
76//#define RGBLIGHT_ANIMATIONS : see ./rules.mk: LED_ANIMATIONS = yes or no 64//#define RGBLIGHT_ANIMATIONS : see ./rules.mk: LED_ANIMATIONS = yes or no
77// see ./rules.mk: LED_BACK_ENABLE or LED_UNDERGLOW_ENABLE set yes 65// see ./rules.mk: LED_BACK_ENABLE or LED_UNDERGLOW_ENABLE set yes
78#ifdef RGBLED_BACK 66#ifdef RGBLIGHT_ENABLE
79 #define RGBLED_NUM 24 67 #define RGBLIGHT_SPLIT
80#else 68 #ifdef RGBLED_BACK
81 #define RGBLED_NUM 6 69 #ifdef RGBLED_CONT
70 #define RGBLED_NUM 48
71 #define RGBLED_SPLIT { 24, 24 }
72 #else
73 #define RGBLED_NUM 24
74 #endif
75 #else
76 #ifdef RGBLED_BOTH
77 #ifdef RGBLED_CONT
78 #define RGBLED_NUM 60
79 #define RGBLED_SPLIT { 30, 30 }
80// #define RGBLIGHT_LED_MAP {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29}
81 #else
82 #define RGBLED_NUM 30
83 #endif
84 #else
85 #ifdef RGBLED_CONT
86 #define RGBLED_NUM 12
87 #define RGBLED_SPLIT { 6, 6 }
88 #else
89 #define RGBLED_NUM 6
90 #endif
91 #endif
92 #endif
82#endif 93#endif
83 94
84#ifndef IOS_DEVICE_ENABLE 95#ifndef IOS_DEVICE_ENABLE
85 #if RGBLED_NUM <= 6 96 #if (RGBLED_NUM <= 6) || (defined(RGBLED_CONT) && (RGBLED_NUM <= 12))
86 #define RGBLIGHT_LIMIT_VAL 255 97 #define RGBLIGHT_LIMIT_VAL 255
87 #else 98 #else
88 #if RGBLED_NUM <= 16 99 #if (RGBLED_NUM <= 16) || (defined(RGBLED_CONT) && (RGBLED_NUM <= 32))
89 #define RGBLIGHT_LIMIT_VAL 130 100 #define RGBLIGHT_LIMIT_VAL 130
90 #else 101 #else
91 #define RGBLIGHT_LIMIT_VAL 120 102 #define RGBLIGHT_LIMIT_VAL 120
@@ -93,10 +104,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
93 #endif 104 #endif
94 #define RGBLIGHT_VAL_STEP 17 105 #define RGBLIGHT_VAL_STEP 17
95#else 106#else
96 #if RGBLED_NUM <= 6 107 #if (RGBLED_NUM <= 6) || (defined(RGBLED_CONT) && (RGBLED_NUM <= 12))
97 #define RGBLIGHT_LIMIT_VAL 90 108 #define RGBLIGHT_LIMIT_VAL 90
98 #else 109 #else
99 #if RGBLED_NUM <= 16 110 #if (RGBLED_NUM <= 16) || (defined(RGBLED_CONT) && (RGBLED_NUM <= 32))
100 #define RGBLIGHT_LIMIT_VAL 45 111 #define RGBLIGHT_LIMIT_VAL 45
101 #else 112 #else
102 #define RGBLIGHT_LIMIT_VAL 35 113 #define RGBLIGHT_LIMIT_VAL 35
@@ -136,5 +147,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
136//#define NO_ACTION_ONESHOT 147//#define NO_ACTION_ONESHOT
137//#define NO_ACTION_MACRO 148//#define NO_ACTION_MACRO
138//#define NO_ACTION_FUNCTION 149//#define NO_ACTION_FUNCTION
139
140//#endif
diff --git a/keyboards/zinc/rev1/matrix.c b/keyboards/zinc/rev1/matrix.c
deleted file mode 100644
index df674ce14..000000000
--- a/keyboards/zinc/rev1/matrix.c
+++ /dev/null
@@ -1,357 +0,0 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18/*
19 * scan matrix
20 */
21#include <stdint.h>
22#include <stdbool.h>
23#include <string.h>
24#include <avr/io.h>
25#include <avr/wdt.h>
26#include <avr/interrupt.h>
27#include <util/delay.h>
28#include "print.h"
29#include "debug.h"
30#include "util.h"
31#include "matrix.h"
32#include "split_util.h"
33#include "quantum.h"
34
35#ifdef USE_MATRIX_I2C
36# include "i2c.h"
37#else // USE_SERIAL
38# include "split_scomm.h"
39#endif
40
41#ifndef DEBOUNCE
42# define DEBOUNCE 5
43#endif
44
45#define ERROR_DISCONNECT_COUNT 5
46
47static uint8_t debouncing = DEBOUNCE;
48static const int ROWS_PER_HAND = MATRIX_ROWS/2;
49static uint8_t error_count = 0;
50uint8_t is_master = 0 ;
51
52static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
53static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
54
55/* matrix state(1:on, 0:off) */
56static matrix_row_t matrix[MATRIX_ROWS];
57static matrix_row_t matrix_debouncing[MATRIX_ROWS];
58
59static matrix_row_t read_cols(void);
60static void init_cols(void);
61static void unselect_rows(void);
62static void select_row(uint8_t row);
63static uint8_t matrix_master_scan(void);
64
65
66__attribute__ ((weak))
67void matrix_init_kb(void) {
68 matrix_init_user();
69}
70
71__attribute__ ((weak))
72void matrix_scan_kb(void) {
73 matrix_scan_user();
74}
75
76__attribute__ ((weak))
77void matrix_init_user(void) {
78}
79
80__attribute__ ((weak))
81void matrix_scan_user(void) {
82}
83
84inline
85uint8_t matrix_rows(void)
86{
87 return MATRIX_ROWS;
88}
89
90inline
91uint8_t matrix_cols(void)
92{
93 return MATRIX_COLS;
94}
95
96void matrix_init(void)
97{
98 debug_enable = true;
99 debug_matrix = true;
100 debug_mouse = true;
101 // initialize row and col
102 unselect_rows();
103 init_cols();
104
105 setPinOutput(B0);
106 setPinOutput(D5);
107 writePinHigh(D5);
108 writePinHigh(B0);
109
110 // initialize matrix state: all keys off
111 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
112 matrix[i] = 0;
113 matrix_debouncing[i] = 0;
114 }
115
116 is_master = has_usb();
117
118 matrix_init_quantum();
119}
120
121uint8_t _matrix_scan(void)
122{
123 // Right hand is stored after the left in the matirx so, we need to offset it
124 int offset = isLeftHand ? 0 : (ROWS_PER_HAND);
125
126 for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
127 select_row(i);
128 _delay_us(30); // without this wait read unstable value.
129 matrix_row_t cols = read_cols();
130 if (matrix_debouncing[i+offset] != cols) {
131 matrix_debouncing[i+offset] = cols;
132 debouncing = DEBOUNCE;
133 }
134 unselect_rows();
135 }
136
137 if (debouncing) {
138 if (--debouncing) {
139 _delay_ms(1);
140 } else {
141 for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
142 matrix[i+offset] = matrix_debouncing[i+offset];
143 }
144 }
145 }
146
147 return 1;
148}
149
150#ifdef USE_MATRIX_I2C
151
152// Get rows from other half over i2c
153int i2c_transaction(void) {
154 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
155
156 int err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE);
157 if (err) goto i2c_error;
158
159 // start of matrix stored at 0x00
160 err = i2c_master_write(0x00);
161 if (err) goto i2c_error;
162
163 // Start read
164 err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ);
165 if (err) goto i2c_error;
166
167 if (!err) {
168 int i;
169 for (i = 0; i < ROWS_PER_HAND-1; ++i) {
170 matrix[slaveOffset+i] = i2c_master_read(I2C_ACK);
171 }
172 matrix[slaveOffset+i] = i2c_master_read(I2C_NACK);
173 i2c_master_stop();
174 } else {
175i2c_error: // the cable is disconnceted, or something else went wrong
176 i2c_reset_state();
177 return err;
178 }
179
180 return 0;
181}
182
183#else // USE_SERIAL
184
185int serial_transaction(int master_changed) {
186 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
187#ifdef SERIAL_USE_MULTI_TRANSACTION
188 int ret=serial_update_buffers(master_changed);
189#else
190 int ret=serial_update_buffers();
191#endif
192 if (ret ) {
193 if(ret==2) writePinLow(B0);
194 return 1;
195 }
196 writePinHigh(B0);
197 memcpy(&matrix[slaveOffset],
198 (void *)serial_slave_buffer, sizeof(serial_slave_buffer));
199 return 0;
200}
201#endif
202
203uint8_t matrix_scan(void)
204{
205 if (is_master) {
206 matrix_master_scan();
207 }else{
208 matrix_slave_scan();
209 int offset = (isLeftHand) ? ROWS_PER_HAND : 0;
210 memcpy(&matrix[offset],
211 (void *)serial_master_buffer, sizeof(serial_master_buffer));
212 matrix_scan_quantum();
213 }
214 return 1;
215}
216
217
218uint8_t matrix_master_scan(void) {
219
220 int ret = _matrix_scan();
221 int mchanged = 1;
222 int offset = (isLeftHand) ? 0 : ROWS_PER_HAND;
223
224#ifdef USE_MATRIX_I2C
225// for (int i = 0; i < ROWS_PER_HAND; ++i) {
226 /* i2c_slave_buffer[i] = matrix[offset+i]; */
227// i2c_slave_buffer[i] = matrix[offset+i];
228// }
229#else // USE_SERIAL
230 #ifdef SERIAL_USE_MULTI_TRANSACTION
231 mchanged = memcmp((void *)serial_master_buffer,
232 &matrix[offset], sizeof(serial_master_buffer));
233 #endif
234 memcpy((void *)serial_master_buffer,
235 &matrix[offset], sizeof(serial_master_buffer));
236#endif
237
238#ifdef USE_MATRIX_I2C
239 if( i2c_transaction() ) {
240#else // USE_SERIAL
241 if( serial_transaction(mchanged) ) {
242#endif
243 // turn on the indicator led when halves are disconnected
244 writePinLow(D5);
245
246 error_count++;
247
248 if (error_count > ERROR_DISCONNECT_COUNT) {
249 // reset other half if disconnected
250 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
251 for (int i = 0; i < ROWS_PER_HAND; ++i) {
252 matrix[slaveOffset+i] = 0;
253 }
254 }
255 } else {
256 // turn off the indicator led on no error
257 writePinHigh(D5);
258 error_count = 0;
259 }
260 matrix_scan_quantum();
261 return ret;
262}
263
264void matrix_slave_scan(void) {
265 _matrix_scan();
266
267 int offset = (isLeftHand) ? 0 : ROWS_PER_HAND;
268
269#ifdef USE_MATRIX_I2C
270 for (int i = 0; i < ROWS_PER_HAND; ++i) {
271 /* i2c_slave_buffer[i] = matrix[offset+i]; */
272 i2c_slave_buffer[i] = matrix[offset+i];
273 }
274#else // USE_SERIAL
275 #ifdef SERIAL_USE_MULTI_TRANSACTION
276 int change = 0;
277 #endif
278 for (int i = 0; i < ROWS_PER_HAND; ++i) {
279 #ifdef SERIAL_USE_MULTI_TRANSACTION
280 if( serial_slave_buffer[i] != matrix[offset+i] )
281 change = 1;
282 #endif
283 serial_slave_buffer[i] = matrix[offset+i];
284 }
285 #ifdef SERIAL_USE_MULTI_TRANSACTION
286 slave_buffer_change_count += change;
287 #endif
288#endif
289}
290
291bool matrix_is_modified(void)
292{
293 if (debouncing) return false;
294 return true;
295}
296
297inline
298bool matrix_is_on(uint8_t row, uint8_t col)
299{
300 return (matrix[row] & ((matrix_row_t)1<<col));
301}
302
303inline
304matrix_row_t matrix_get_row(uint8_t row)
305{
306 return matrix[row];
307}
308
309void matrix_print(void)
310{
311 print("\nr/c 0123456789ABCDEF\n");
312 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
313 phex(row); print(": ");
314 pbin_reverse16(matrix_get_row(row));
315 print("\n");
316 }
317}
318
319uint8_t matrix_key_count(void)
320{
321 uint8_t count = 0;
322 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
323 count += bitpop16(matrix[i]);
324 }
325 return count;
326}
327
328static void init_cols(void)
329{
330 for(int x = 0; x < MATRIX_COLS; x++) {
331 _SFR_IO8((col_pins[x] >> 4) + 1) &= ~_BV(col_pins[x] & 0xF);
332 _SFR_IO8((col_pins[x] >> 4) + 2) |= _BV(col_pins[x] & 0xF);
333 }
334}
335
336static matrix_row_t read_cols(void)
337{
338 matrix_row_t result = 0;
339 for(int x = 0; x < MATRIX_COLS; x++) {
340 result |= (_SFR_IO8(col_pins[x] >> 4) & _BV(col_pins[x] & 0xF)) ? 0 : (1 << x);
341 }
342 return result;
343}
344
345static void unselect_rows(void)
346{
347 for(int x = 0; x < ROWS_PER_HAND; x++) {
348 _SFR_IO8((row_pins[x] >> 4) + 1) &= ~_BV(row_pins[x] & 0xF);
349 _SFR_IO8((row_pins[x] >> 4) + 2) |= _BV(row_pins[x] & 0xF);
350 }
351}
352
353static void select_row(uint8_t row)
354{
355 _SFR_IO8((row_pins[row] >> 4) + 1) |= _BV(row_pins[row] & 0xF);
356 _SFR_IO8((row_pins[row] >> 4) + 2) &= ~_BV(row_pins[row] & 0xF);
357}
diff --git a/keyboards/zinc/rev1/rev1.c b/keyboards/zinc/rev1/rev1.c
index 2ce08a07c..a9c2cfdba 100644
--- a/keyboards/zinc/rev1/rev1.c
+++ b/keyboards/zinc/rev1/rev1.c
@@ -3,4 +3,3 @@
3void matrix_init_kb(void) { 3void matrix_init_kb(void) {
4 matrix_init_user(); 4 matrix_init_user();
5}; 5};
6
diff --git a/keyboards/zinc/rev1/rev1.h b/keyboards/zinc/rev1/rev1.h
index aa1c408b0..1bf2c565a 100644
--- a/keyboards/zinc/rev1/rev1.h
+++ b/keyboards/zinc/rev1/rev1.h
@@ -1,22 +1,7 @@
1#pragma once 1#pragma once
2 2
3#include "../zinc.h"
4
5#include "quantum.h" 3#include "quantum.h"
6 4
7#ifdef RGBLIGHT_ENABLE
8//rgb led driver
9#include "ws2812.h"
10#endif
11
12#ifdef USE_I2C
13#include <stddef.h>
14#ifdef __AVR__
15 #include <avr/io.h>
16 #include <avr/interrupt.h>
17#endif
18#endif
19
20// Standard Keymap 5// Standard Keymap
21// (TRRS jack on both halves are to the left side) 6// (TRRS jack on both halves are to the left side)
22#define LAYOUT( \ 7#define LAYOUT( \
diff --git a/keyboards/zinc/rev1/rules.mk b/keyboards/zinc/rev1/rules.mk
index e78b9258d..d38a61809 100644
--- a/keyboards/zinc/rev1/rules.mk
+++ b/keyboards/zinc/rev1/rules.mk
@@ -1,4 +1 @@
1SRC += rev1/matrix.c SPLIT_KEYBOARD = yes
2SRC += rev1/split_util.c
3SRC += rev1/split_scomm.c
4SRC += ws2812.c
diff --git a/keyboards/zinc/rev1/serial_config.h b/keyboards/zinc/rev1/serial_config.h
deleted file mode 100644
index 9fb5dfc67..000000000
--- a/keyboards/zinc/rev1/serial_config.h
+++ /dev/null
@@ -1,18 +0,0 @@
1#ifndef SOFT_SERIAL_CONFIG_H
2#define SOFT_SERIAL_CONFIG_H
3
4#ifndef SOFT_SERIAL_PIN
5/* Soft Serial defines */
6#define SOFT_SERIAL_PIN D2
7// OPTIONAL: #define SELECT_SOFT_SERIAL_SPEED ? // ? = 1,2,3,4,5
8// // 1: about 137kbps (default)
9// // 2: about 75kbps
10// // 3: about 39kbps
11// // 4: about 26kbps
12// // 5: about 20kbps
13#endif
14
15//// USE flexible API (using multi-type transaction function)
16#define SERIAL_USE_MULTI_TRANSACTION
17
18#endif /* SOFT_SERIAL_CONFIG_H */
diff --git a/keyboards/zinc/rev1/serial_config_simpleapi.h b/keyboards/zinc/rev1/serial_config_simpleapi.h
deleted file mode 100644
index e2d22a41e..000000000
--- a/keyboards/zinc/rev1/serial_config_simpleapi.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef SERIAL_CONFIG_SIMPLEAPI_H
2#define SERIAL_CONFIG_SIMPLEAPI_H
3
4#undef SERIAL_USE_MULTI_TRANSACTION
5#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
6#define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2
7
8#endif // SERIAL_CONFIG_SIMPLEAPI_H
diff --git a/keyboards/zinc/rev1/split_scomm.c b/keyboards/zinc/rev1/split_scomm.c
deleted file mode 100644
index 50d233ce9..000000000
--- a/keyboards/zinc/rev1/split_scomm.c
+++ /dev/null
@@ -1,95 +0,0 @@
1#ifdef USE_SERIAL
2#ifdef SERIAL_USE_MULTI_TRANSACTION
3/* --- USE flexible API (using multi-type transaction function) --- */
4
5#include <stdbool.h>
6#include <stdint.h>
7#include <stddef.h>
8#include <split_scomm.h>
9#include "serial.h"
10#ifdef SERIAL_DEBUG_MODE
11#include <avr/io.h>
12#endif
13#ifdef CONSOLE_ENABLE
14 #include <print.h>
15#endif
16
17uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};
18uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
19uint8_t volatile status_com = 0;
20uint8_t volatile status1 = 0;
21uint8_t slave_buffer_change_count = 0;
22uint8_t s_change_old = 0xff;
23uint8_t s_change_new = 0xff;
24
25SSTD_t transactions[] = {
26#define GET_SLAVE_STATUS 0
27 /* master buffer not changed, only recive slave_buffer_change_count */
28 { (uint8_t *)&status_com,
29 0, NULL,
30 sizeof(slave_buffer_change_count), &slave_buffer_change_count,
31 },
32#define PUT_MASTER_GET_SLAVE_STATUS 1
33 /* master buffer changed need send, and recive slave_buffer_change_count */
34 { (uint8_t *)&status_com,
35 sizeof(serial_master_buffer), (uint8_t *)serial_master_buffer,
36 sizeof(slave_buffer_change_count), &slave_buffer_change_count,
37 },
38#define GET_SLAVE_BUFFER 2
39 /* recive serial_slave_buffer */
40 { (uint8_t *)&status1,
41 0, NULL,
42 sizeof(serial_slave_buffer), (uint8_t *)serial_slave_buffer
43 }
44};
45
46void serial_master_init(void)
47{
48 soft_serial_initiator_init(transactions, TID_LIMIT(transactions));
49}
50
51void serial_slave_init(void)
52{
53 soft_serial_target_init(transactions, TID_LIMIT(transactions));
54}
55
56// 0 => no error
57// 1 => slave did not respond
58// 2 => checksum error
59int serial_update_buffers(int master_update)
60{
61 int status, smatstatus;
62 static int need_retry = 0;
63
64 if( s_change_old != s_change_new ) {
65 smatstatus = soft_serial_transaction(GET_SLAVE_BUFFER);
66 if( smatstatus == TRANSACTION_END ) {
67 s_change_old = s_change_new;
68#ifdef CONSOLE_ENABLE
69 uprintf("slave matrix = %b %b %b %b %b\n",
70 serial_slave_buffer[0], serial_slave_buffer[1],
71 serial_slave_buffer[2], serial_slave_buffer[3],
72 serial_slave_buffer[4] );
73#endif
74 }
75 } else {
76 // serial_slave_buffer dosen't change
77 smatstatus = TRANSACTION_END; // dummy status
78 }
79
80 if( !master_update && !need_retry) {
81 status = soft_serial_transaction(GET_SLAVE_STATUS);
82 } else {
83 status = soft_serial_transaction(PUT_MASTER_GET_SLAVE_STATUS);
84 }
85 if( status == TRANSACTION_END ) {
86 s_change_new = slave_buffer_change_count;
87 need_retry = 0;
88 } else {
89 need_retry = 1;
90 }
91 return smatstatus;
92}
93
94#endif // SERIAL_USE_MULTI_TRANSACTION
95#endif /* USE_SERIAL */
diff --git a/keyboards/zinc/rev1/split_scomm.h b/keyboards/zinc/rev1/split_scomm.h
deleted file mode 100644
index 873d8939d..000000000
--- a/keyboards/zinc/rev1/split_scomm.h
+++ /dev/null
@@ -1,24 +0,0 @@
1#ifndef SPLIT_COMM_H
2#define SPLIT_COMM_H
3
4#ifndef SERIAL_USE_MULTI_TRANSACTION
5/* --- USE Simple API (OLD API, compatible with let's split serial.c) --- */
6#include "serial.h"
7
8#else
9/* --- USE flexible API (using multi-type transaction function) --- */
10// Buffers for master - slave communication
11#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
12#define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2
13
14extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
15extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
16extern uint8_t slave_buffer_change_count;
17
18void serial_master_init(void);
19void serial_slave_init(void);
20int serial_update_buffers(int master_changed);
21
22#endif
23
24#endif /* SPLIT_COMM_H */
diff --git a/keyboards/zinc/rev1/split_util.c b/keyboards/zinc/rev1/split_util.c
deleted file mode 100644
index e1ff8b437..000000000
--- a/keyboards/zinc/rev1/split_util.c
+++ /dev/null
@@ -1,70 +0,0 @@
1#include <avr/io.h>
2#include <avr/wdt.h>
3#include <avr/power.h>
4#include <avr/interrupt.h>
5#include <util/delay.h>
6#include <avr/eeprom.h>
7#include "split_util.h"
8#include "matrix.h"
9#include "keyboard.h"
10
11#ifdef USE_MATRIX_I2C
12# include "i2c.h"
13#else
14# include "split_scomm.h"
15#endif
16
17volatile bool isLeftHand = true;
18
19static void setup_handedness(void) {
20 #ifdef EE_HANDS
21 isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS);
22 #else
23 // I2C_MASTER_RIGHT is deprecated, use MASTER_RIGHT instead, since this works for both serial and i2c
24 #if defined(I2C_MASTER_RIGHT) || defined(MASTER_RIGHT)
25 isLeftHand = !has_usb();
26 #else
27 isLeftHand = has_usb();
28 #endif
29 #endif
30}
31
32static void keyboard_master_setup(void) {
33
34#ifdef USE_MATRIX_I2C
35 i2c_master_init();
36#else
37 serial_master_init();
38#endif
39}
40
41static void keyboard_slave_setup(void) {
42
43#ifdef USE_MATRIX_I2C
44 i2c_slave_init(SLAVE_I2C_ADDRESS);
45#else
46 serial_slave_init();
47#endif
48}
49
50bool has_usb(void) {
51 USBCON |= (1 << OTGPADE); //enables VBUS pad
52 _delay_us(5);
53 return (USBSTA & (1<<VBUS)); //checks state of VBUS
54}
55
56void split_keyboard_setup(void) {
57 setup_handedness();
58
59 if (has_usb()) {
60 keyboard_master_setup();
61 } else {
62 keyboard_slave_setup();
63 }
64 sei();
65}
66
67// this code runs before the usb and keyboard is initialized
68void matrix_setup(void) {
69 split_keyboard_setup();
70}
diff --git a/keyboards/zinc/rev1/split_util.h b/keyboards/zinc/rev1/split_util.h
deleted file mode 100644
index 687ca19bd..000000000
--- a/keyboards/zinc/rev1/split_util.h
+++ /dev/null
@@ -1,19 +0,0 @@
1#ifndef SPLIT_KEYBOARD_UTIL_H
2#define SPLIT_KEYBOARD_UTIL_H
3
4#include <stdbool.h>
5#include "eeconfig.h"
6
7#define SLAVE_I2C_ADDRESS 0x32
8
9extern volatile bool isLeftHand;
10
11// slave version of matix scan, defined in matrix.c
12void matrix_slave_scan(void);
13
14void split_keyboard_setup(void);
15bool has_usb(void);
16
17void matrix_master_OLED_init (void);
18
19#endif
diff --git a/keyboards/zinc/reva/config.h b/keyboards/zinc/reva/config.h
index 8eeb154ac..e94ffb7c6 100644
--- a/keyboards/zinc/reva/config.h
+++ b/keyboards/zinc/reva/config.h
@@ -30,9 +30,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
30#define TAPPING_TERM 100 30#define TAPPING_TERM 100
31 31
32/* Use I2C or Serial */ 32/* Use I2C or Serial */
33//#define USE_I2C
34#define USE_SERIAL 33#define USE_SERIAL
35//#define USE_MATRIX_I2C 34#define SOFT_SERIAL_PIN D2
36 35
37/* Select hand configuration */ 36/* Select hand configuration */
38#define MASTER_LEFT 37#define MASTER_LEFT
@@ -41,18 +40,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
41 40
42/* key matrix size */ 41/* key matrix size */
43// Rows are doubled-up 42// Rows are doubled-up
44 #define MATRIX_ROWS 8 43#define MATRIX_ROWS 8
45 #define MATRIX_ROW_PINS { D4, C6, D7, E6 } 44#define MATRIX_ROW_PINS { D4, C6, D7, E6 }
46 45
47// wiring of each half 46// wiring of each half
48#define MATRIX_COLS 6 47#define MATRIX_COLS 6
49#define MATRIX_COL_PINS { F4, F5, F6, F7, B1, B3} 48#define MATRIX_COL_PINS { F4, F5, F6, F7, B1, B3}
50 49
51/* define if matrix has ghost */ 50#define DIODE_DIRECTION COL2ROW
52//#define MATRIX_HAS_GHOST
53
54/* number of backlight levels */
55// #define BACKLIGHT_LEVELS 3
56 51
57/* Set 0 if debouncing isn't needed */ 52/* Set 0 if debouncing isn't needed */
58#define DEBOUNCE 5 53#define DEBOUNCE 5
@@ -64,25 +59,44 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
64 59
65/* ws2812 RGB LED */ 60/* ws2812 RGB LED */
66#define RGB_DI_PIN D3 61#define RGB_DI_PIN D3
67#define RGBLIGHT_TIMER
68//#define RGBLED_NUM 24 // Number of LEDs. see ./keymaps/default/config.h
69#define ws2812_PORTREG PORTD
70#define ws2812_DDRREG DDRD
71 62
72// RGB LED support 63// RGB LED support
73//#define RGBLIGHT_ANIMATIONS : see ./rules.mk: LED_ANIMATIONS = yes or no 64//#define RGBLIGHT_ANIMATIONS : see ./rules.mk: LED_ANIMATIONS = yes or no
74// see ./rules.mk: LED_BACK_ENABLE or LED_UNDERGLOW_ENABLE set yes 65// see ./rules.mk: LED_BACK_ENABLE or LED_UNDERGLOW_ENABLE set yes
75#ifdef RGBLED_BACK 66#ifdef RGBLIGHT_ENABLE
76 #define RGBLED_NUM 24 67 #define RGBLIGHT_SPLIT
77#else 68 #ifdef RGBLED_BACK
78 #define RGBLED_NUM 6 69 #ifdef RGBLED_CONT
70 #define RGBLED_NUM 48
71 #define RGBLED_SPLIT { 24, 24 }
72 #else
73 #define RGBLED_NUM 24
74 #endif
75 #else
76 #ifdef RGBLED_BOTH
77 #ifdef RGBLED_CONT
78 #define RGBLED_NUM 60
79 #define RGBLED_SPLIT { 30, 30 }
80// #define RGBLIGHT_LED_MAP {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29}
81 #else
82 #define RGBLED_NUM 30
83 #endif
84 #else
85 #ifdef RGBLED_CONT
86 #define RGBLED_NUM 12
87 #define RGBLED_SPLIT { 6, 6 }
88 #else
89 #define RGBLED_NUM 6
90 #endif
91 #endif
92 #endif
79#endif 93#endif
80 94
81#ifndef IOS_DEVICE_ENABLE 95#ifndef IOS_DEVICE_ENABLE
82 #if RGBLED_NUM <= 6 96 #if (RGBLED_NUM <= 6) || (defined(RGBLED_CONT) && (RGBLED_NUM <= 12))
83 #define RGBLIGHT_LIMIT_VAL 255 97 #define RGBLIGHT_LIMIT_VAL 255
84 #else 98 #else
85 #if RGBLED_NUM <= 16 99 #if (RGBLED_NUM <= 16) || (defined(RGBLED_CONT) && (RGBLED_NUM <= 32))
86 #define RGBLIGHT_LIMIT_VAL 130 100 #define RGBLIGHT_LIMIT_VAL 130
87 #else 101 #else
88 #define RGBLIGHT_LIMIT_VAL 120 102 #define RGBLIGHT_LIMIT_VAL 120
@@ -90,10 +104,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
90 #endif 104 #endif
91 #define RGBLIGHT_VAL_STEP 17 105 #define RGBLIGHT_VAL_STEP 17
92#else 106#else
93 #if RGBLED_NUM <= 6 107 #if (RGBLED_NUM <= 6) || (defined(RGBLED_CONT) && (RGBLED_NUM <= 12))
94 #define RGBLIGHT_LIMIT_VAL 90 108 #define RGBLIGHT_LIMIT_VAL 90
95 #else 109 #else
96 #if RGBLED_NUM <= 16 110 #if (RGBLED_NUM <= 16) || (defined(RGBLED_CONT) && (RGBLED_NUM <= 32))
97 #define RGBLIGHT_LIMIT_VAL 45 111 #define RGBLIGHT_LIMIT_VAL 45
98 #else 112 #else
99 #define RGBLIGHT_LIMIT_VAL 35 113 #define RGBLIGHT_LIMIT_VAL 35
diff --git a/keyboards/zinc/reva/matrix.c b/keyboards/zinc/reva/matrix.c
deleted file mode 100644
index 5b58500db..000000000
--- a/keyboards/zinc/reva/matrix.c
+++ /dev/null
@@ -1,357 +0,0 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18/*
19 * scan matrix
20 */
21#include <stdint.h>
22#include <stdbool.h>
23#include <string.h>
24#include <avr/io.h>
25#include <avr/wdt.h>
26#include <avr/interrupt.h>
27#include <util/delay.h>
28#include "print.h"
29#include "debug.h"
30#include "util.h"
31#include "matrix.h"
32#include "split_util.h"
33#include "quantum.h"
34
35#ifdef USE_MATRIX_I2C
36# include "i2c.h"
37#else // USE_SERIAL
38# include "split_scomm.h"
39#endif
40
41#ifndef DEBOUNCE
42# define DEBOUNCE 5
43#endif
44
45#define ERROR_DISCONNECT_COUNT 5
46
47static uint8_t debouncing = DEBOUNCE;
48static const int ROWS_PER_HAND = MATRIX_ROWS/2;
49static uint8_t error_count = 0;
50uint8_t is_master = 0 ;
51
52static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
53static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
54
55/* matrix state(1:on, 0:off) */
56static matrix_row_t matrix[MATRIX_ROWS];
57static matrix_row_t matrix_debouncing[MATRIX_ROWS];
58
59static matrix_row_t read_cols(void);
60static void init_cols(void);
61static void unselect_rows(void);
62static void select_row(uint8_t row);
63static uint8_t matrix_master_scan(void);
64
65
66__attribute__ ((weak))
67void matrix_init_kb(void) {
68 matrix_init_user();
69}
70
71__attribute__ ((weak))
72void matrix_scan_kb(void) {
73 matrix_scan_user();
74}
75
76__attribute__ ((weak))
77void matrix_init_user(void) {
78}
79
80__attribute__ ((weak))
81void matrix_scan_user(void) {
82}
83
84inline
85uint8_t matrix_rows(void)
86{
87 return MATRIX_ROWS;
88}
89
90inline
91uint8_t matrix_cols(void)
92{
93 return MATRIX_COLS;
94}
95
96void matrix_init(void)
97{
98 debug_enable = true;
99 debug_matrix = true;
100 debug_mouse = true;
101 // initialize row and col
102 unselect_rows();
103 init_cols();
104
105 setPinOutput(B0);
106 setPinOutput(D5);
107 writePinHigh(B0);
108 writePinHigh(D5);
109
110 // initialize matrix state: all keys off
111 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
112 matrix[i] = 0;
113 matrix_debouncing[i] = 0;
114 }
115
116 is_master = has_usb();
117
118 matrix_init_quantum();
119}
120
121uint8_t _matrix_scan(void)
122{
123 // Right hand is stored after the left in the matirx so, we need to offset it
124 int offset = isLeftHand ? 0 : (ROWS_PER_HAND);
125
126 for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
127 select_row(i);
128 _delay_us(30); // without this wait read unstable value.
129 matrix_row_t cols = read_cols();
130 if (matrix_debouncing[i+offset] != cols) {
131 matrix_debouncing[i+offset] = cols;
132 debouncing = DEBOUNCE;
133 }
134 unselect_rows();
135 }
136
137 if (debouncing) {
138 if (--debouncing) {
139 _delay_ms(1);
140 } else {
141 for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
142 matrix[i+offset] = matrix_debouncing[i+offset];
143 }
144 }
145 }
146
147 return 1;
148}
149
150#ifdef USE_MATRIX_I2C
151
152// Get rows from other half over i2c
153int i2c_transaction(void) {
154 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
155
156 int err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE);
157 if (err) goto i2c_error;
158
159 // start of matrix stored at 0x00
160 err = i2c_master_write(0x00);
161 if (err) goto i2c_error;
162
163 // Start read
164 err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ);
165 if (err) goto i2c_error;
166
167 if (!err) {
168 int i;
169 for (i = 0; i < ROWS_PER_HAND-1; ++i) {
170 matrix[slaveOffset+i] = i2c_master_read(I2C_ACK);
171 }
172 matrix[slaveOffset+i] = i2c_master_read(I2C_NACK);
173 i2c_master_stop();
174 } else {
175i2c_error: // the cable is disconnceted, or something else went wrong
176 i2c_reset_state();
177 return err;
178 }
179
180 return 0;
181}
182
183#else // USE_SERIAL
184
185int serial_transaction(int master_changed) {
186 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
187#ifdef SERIAL_USE_MULTI_TRANSACTION
188 int ret=serial_update_buffers(master_changed);
189#else
190 int ret=serial_update_buffers();
191#endif
192 if (ret ) {
193 if(ret==2) writePinLow(B0);
194 return 1;
195 }
196 writePinHigh(B0);
197 memcpy(&matrix[slaveOffset],
198 (void *)serial_slave_buffer, sizeof(serial_slave_buffer));
199 return 0;
200}
201#endif
202
203uint8_t matrix_scan(void)
204{
205 if (is_master) {
206 matrix_master_scan();
207 }else{
208 matrix_slave_scan();
209 int offset = (isLeftHand) ? ROWS_PER_HAND : 0;
210 memcpy(&matrix[offset],
211 (void *)serial_master_buffer, sizeof(serial_master_buffer));
212 matrix_scan_quantum();
213 }
214 return 1;
215}
216
217
218uint8_t matrix_master_scan(void) {
219
220 int ret = _matrix_scan();
221 int mchanged = 1;
222 int offset = (isLeftHand) ? 0 : ROWS_PER_HAND;
223
224#ifdef USE_MATRIX_I2C
225// for (int i = 0; i < ROWS_PER_HAND; ++i) {
226 /* i2c_slave_buffer[i] = matrix[offset+i]; */
227// i2c_slave_buffer[i] = matrix[offset+i];
228// }
229#else // USE_SERIAL
230 #ifdef SERIAL_USE_MULTI_TRANSACTION
231 mchanged = memcmp((void *)serial_master_buffer,
232 &matrix[offset], sizeof(serial_master_buffer));
233 #endif
234 memcpy((void *)serial_master_buffer,
235 &matrix[offset], sizeof(serial_master_buffer));
236#endif
237
238#ifdef USE_MATRIX_I2C
239 if( i2c_transaction() ) {
240#else // USE_SERIAL
241 if( serial_transaction(mchanged) ) {
242#endif
243 // turn on the indicator led when halves are disconnected
244 writePinLow(D5);
245
246 error_count++;
247
248 if (error_count > ERROR_DISCONNECT_COUNT) {
249 // reset other half if disconnected
250 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
251 for (int i = 0; i < ROWS_PER_HAND; ++i) {
252 matrix[slaveOffset+i] = 0;
253 }
254 }
255 } else {
256 // turn off the indicator led on no error
257 writePinHigh(D5);
258 error_count = 0;
259 }
260 matrix_scan_quantum();
261 return ret;
262}
263
264void matrix_slave_scan(void) {
265 _matrix_scan();
266
267 int offset = (isLeftHand) ? 0 : ROWS_PER_HAND;
268
269#ifdef USE_MATRIX_I2C
270 for (int i = 0; i < ROWS_PER_HAND; ++i) {
271 /* i2c_slave_buffer[i] = matrix[offset+i]; */
272 i2c_slave_buffer[i] = matrix[offset+i];
273 }
274#else // USE_SERIAL
275 #ifdef SERIAL_USE_MULTI_TRANSACTION
276 int change = 0;
277 #endif
278 for (int i = 0; i < ROWS_PER_HAND; ++i) {
279 #ifdef SERIAL_USE_MULTI_TRANSACTION
280 if( serial_slave_buffer[i] != matrix[offset+i] )
281 change = 1;
282 #endif
283 serial_slave_buffer[i] = matrix[offset+i];
284 }
285 #ifdef SERIAL_USE_MULTI_TRANSACTION
286 slave_buffer_change_count += change;
287 #endif
288#endif
289}
290
291bool matrix_is_modified(void)
292{
293 if (debouncing) return false;
294 return true;
295}
296
297inline
298bool matrix_is_on(uint8_t row, uint8_t col)
299{
300 return (matrix[row] & ((matrix_row_t)1<<col));
301}
302
303inline
304matrix_row_t matrix_get_row(uint8_t row)
305{
306 return matrix[row];
307}
308
309void matrix_print(void)
310{
311 print("\nr/c 0123456789ABCDEF\n");
312 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
313 phex(row); print(": ");
314 pbin_reverse16(matrix_get_row(row));
315 print("\n");
316 }
317}
318
319uint8_t matrix_key_count(void)
320{
321 uint8_t count = 0;
322 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
323 count += bitpop16(matrix[i]);
324 }
325 return count;
326}
327
328static void init_cols(void)
329{
330 for(int x = 0; x < MATRIX_COLS; x++) {
331 _SFR_IO8((col_pins[x] >> 4) + 1) &= ~_BV(col_pins[x] & 0xF);
332 _SFR_IO8((col_pins[x] >> 4) + 2) |= _BV(col_pins[x] & 0xF);
333 }
334}
335
336static matrix_row_t read_cols(void)
337{
338 matrix_row_t result = 0;
339 for(int x = 0; x < MATRIX_COLS; x++) {
340 result |= (_SFR_IO8(col_pins[x] >> 4) & _BV(col_pins[x] & 0xF)) ? 0 : (1 << x);
341 }
342 return result;
343}
344
345static void unselect_rows(void)
346{
347 for(int x = 0; x < ROWS_PER_HAND; x++) {
348 _SFR_IO8((row_pins[x] >> 4) + 1) &= ~_BV(row_pins[x] & 0xF);
349 _SFR_IO8((row_pins[x] >> 4) + 2) |= _BV(row_pins[x] & 0xF);
350 }
351}
352
353static void select_row(uint8_t row)
354{
355 _SFR_IO8((row_pins[row] >> 4) + 1) |= _BV(row_pins[row] & 0xF);
356 _SFR_IO8((row_pins[row] >> 4) + 2) &= ~_BV(row_pins[row] & 0xF);
357}
diff --git a/keyboards/zinc/reva/reva.c b/keyboards/zinc/reva/reva.c
index 2ce08a07c..a9c2cfdba 100644
--- a/keyboards/zinc/reva/reva.c
+++ b/keyboards/zinc/reva/reva.c
@@ -3,4 +3,3 @@
3void matrix_init_kb(void) { 3void matrix_init_kb(void) {
4 matrix_init_user(); 4 matrix_init_user();
5}; 5};
6
diff --git a/keyboards/zinc/reva/reva.h b/keyboards/zinc/reva/reva.h
index aa1c408b0..1bf2c565a 100644
--- a/keyboards/zinc/reva/reva.h
+++ b/keyboards/zinc/reva/reva.h
@@ -1,22 +1,7 @@
1#pragma once 1#pragma once
2 2
3#include "../zinc.h"
4
5#include "quantum.h" 3#include "quantum.h"
6 4
7#ifdef RGBLIGHT_ENABLE
8//rgb led driver
9#include "ws2812.h"
10#endif
11
12#ifdef USE_I2C
13#include <stddef.h>
14#ifdef __AVR__
15 #include <avr/io.h>
16 #include <avr/interrupt.h>
17#endif
18#endif
19
20// Standard Keymap 5// Standard Keymap
21// (TRRS jack on both halves are to the left side) 6// (TRRS jack on both halves are to the left side)
22#define LAYOUT( \ 7#define LAYOUT( \
diff --git a/keyboards/zinc/reva/rules.mk b/keyboards/zinc/reva/rules.mk
index 3ea61267a..83895bdcb 100644
--- a/keyboards/zinc/reva/rules.mk
+++ b/keyboards/zinc/reva/rules.mk
@@ -1,4 +1 @@
1SRC += reva/matrix.c SPLIT_KEYBOARD = yes \ No newline at end of file
2SRC += reva/split_util.c
3SRC += reva/split_scomm.c
4SRC += ws2812.c
diff --git a/keyboards/zinc/reva/serial_config.h b/keyboards/zinc/reva/serial_config.h
deleted file mode 100644
index 9fb5dfc67..000000000
--- a/keyboards/zinc/reva/serial_config.h
+++ /dev/null
@@ -1,18 +0,0 @@
1#ifndef SOFT_SERIAL_CONFIG_H
2#define SOFT_SERIAL_CONFIG_H
3
4#ifndef SOFT_SERIAL_PIN
5/* Soft Serial defines */
6#define SOFT_SERIAL_PIN D2
7// OPTIONAL: #define SELECT_SOFT_SERIAL_SPEED ? // ? = 1,2,3,4,5
8// // 1: about 137kbps (default)
9// // 2: about 75kbps
10// // 3: about 39kbps
11// // 4: about 26kbps
12// // 5: about 20kbps
13#endif
14
15//// USE flexible API (using multi-type transaction function)
16#define SERIAL_USE_MULTI_TRANSACTION
17
18#endif /* SOFT_SERIAL_CONFIG_H */
diff --git a/keyboards/zinc/reva/serial_config_simpleapi.h b/keyboards/zinc/reva/serial_config_simpleapi.h
deleted file mode 100644
index e2d22a41e..000000000
--- a/keyboards/zinc/reva/serial_config_simpleapi.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef SERIAL_CONFIG_SIMPLEAPI_H
2#define SERIAL_CONFIG_SIMPLEAPI_H
3
4#undef SERIAL_USE_MULTI_TRANSACTION
5#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
6#define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2
7
8#endif // SERIAL_CONFIG_SIMPLEAPI_H
diff --git a/keyboards/zinc/reva/split_scomm.c b/keyboards/zinc/reva/split_scomm.c
deleted file mode 100644
index 50d233ce9..000000000
--- a/keyboards/zinc/reva/split_scomm.c
+++ /dev/null
@@ -1,95 +0,0 @@
1#ifdef USE_SERIAL
2#ifdef SERIAL_USE_MULTI_TRANSACTION
3/* --- USE flexible API (using multi-type transaction function) --- */
4
5#include <stdbool.h>
6#include <stdint.h>
7#include <stddef.h>
8#include <split_scomm.h>
9#include "serial.h"
10#ifdef SERIAL_DEBUG_MODE
11#include <avr/io.h>
12#endif
13#ifdef CONSOLE_ENABLE
14 #include <print.h>
15#endif
16
17uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};
18uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
19uint8_t volatile status_com = 0;
20uint8_t volatile status1 = 0;
21uint8_t slave_buffer_change_count = 0;
22uint8_t s_change_old = 0xff;
23uint8_t s_change_new = 0xff;
24
25SSTD_t transactions[] = {
26#define GET_SLAVE_STATUS 0
27 /* master buffer not changed, only recive slave_buffer_change_count */
28 { (uint8_t *)&status_com,
29 0, NULL,
30 sizeof(slave_buffer_change_count), &slave_buffer_change_count,
31 },
32#define PUT_MASTER_GET_SLAVE_STATUS 1
33 /* master buffer changed need send, and recive slave_buffer_change_count */
34 { (uint8_t *)&status_com,
35 sizeof(serial_master_buffer), (uint8_t *)serial_master_buffer,
36 sizeof(slave_buffer_change_count), &slave_buffer_change_count,
37 },
38#define GET_SLAVE_BUFFER 2
39 /* recive serial_slave_buffer */
40 { (uint8_t *)&status1,
41 0, NULL,
42 sizeof(serial_slave_buffer), (uint8_t *)serial_slave_buffer
43 }
44};
45
46void serial_master_init(void)
47{
48 soft_serial_initiator_init(transactions, TID_LIMIT(transactions));
49}
50
51void serial_slave_init(void)
52{
53 soft_serial_target_init(transactions, TID_LIMIT(transactions));
54}
55
56// 0 => no error
57// 1 => slave did not respond
58// 2 => checksum error
59int serial_update_buffers(int master_update)
60{
61 int status, smatstatus;
62 static int need_retry = 0;
63
64 if( s_change_old != s_change_new ) {
65 smatstatus = soft_serial_transaction(GET_SLAVE_BUFFER);
66 if( smatstatus == TRANSACTION_END ) {
67 s_change_old = s_change_new;
68#ifdef CONSOLE_ENABLE
69 uprintf("slave matrix = %b %b %b %b %b\n",
70 serial_slave_buffer[0], serial_slave_buffer[1],
71 serial_slave_buffer[2], serial_slave_buffer[3],
72 serial_slave_buffer[4] );
73#endif
74 }
75 } else {
76 // serial_slave_buffer dosen't change
77 smatstatus = TRANSACTION_END; // dummy status
78 }
79
80 if( !master_update && !need_retry) {
81 status = soft_serial_transaction(GET_SLAVE_STATUS);
82 } else {
83 status = soft_serial_transaction(PUT_MASTER_GET_SLAVE_STATUS);
84 }
85 if( status == TRANSACTION_END ) {
86 s_change_new = slave_buffer_change_count;
87 need_retry = 0;
88 } else {
89 need_retry = 1;
90 }
91 return smatstatus;
92}
93
94#endif // SERIAL_USE_MULTI_TRANSACTION
95#endif /* USE_SERIAL */
diff --git a/keyboards/zinc/reva/split_scomm.h b/keyboards/zinc/reva/split_scomm.h
deleted file mode 100644
index 873d8939d..000000000
--- a/keyboards/zinc/reva/split_scomm.h
+++ /dev/null
@@ -1,24 +0,0 @@
1#ifndef SPLIT_COMM_H
2#define SPLIT_COMM_H
3
4#ifndef SERIAL_USE_MULTI_TRANSACTION
5/* --- USE Simple API (OLD API, compatible with let's split serial.c) --- */
6#include "serial.h"
7
8#else
9/* --- USE flexible API (using multi-type transaction function) --- */
10// Buffers for master - slave communication
11#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
12#define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2
13
14extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
15extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
16extern uint8_t slave_buffer_change_count;
17
18void serial_master_init(void);
19void serial_slave_init(void);
20int serial_update_buffers(int master_changed);
21
22#endif
23
24#endif /* SPLIT_COMM_H */
diff --git a/keyboards/zinc/reva/split_util.c b/keyboards/zinc/reva/split_util.c
deleted file mode 100644
index e1ff8b437..000000000
--- a/keyboards/zinc/reva/split_util.c
+++ /dev/null
@@ -1,70 +0,0 @@
1#include <avr/io.h>
2#include <avr/wdt.h>
3#include <avr/power.h>
4#include <avr/interrupt.h>
5#include <util/delay.h>
6#include <avr/eeprom.h>
7#include "split_util.h"
8#include "matrix.h"
9#include "keyboard.h"
10
11#ifdef USE_MATRIX_I2C
12# include "i2c.h"
13#else
14# include "split_scomm.h"
15#endif
16
17volatile bool isLeftHand = true;
18
19static void setup_handedness(void) {
20 #ifdef EE_HANDS
21 isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS);
22 #else
23 // I2C_MASTER_RIGHT is deprecated, use MASTER_RIGHT instead, since this works for both serial and i2c
24 #if defined(I2C_MASTER_RIGHT) || defined(MASTER_RIGHT)
25 isLeftHand = !has_usb();
26 #else
27 isLeftHand = has_usb();
28 #endif
29 #endif
30}
31
32static void keyboard_master_setup(void) {
33
34#ifdef USE_MATRIX_I2C
35 i2c_master_init();
36#else
37 serial_master_init();
38#endif
39}
40
41static void keyboard_slave_setup(void) {
42
43#ifdef USE_MATRIX_I2C
44 i2c_slave_init(SLAVE_I2C_ADDRESS);
45#else
46 serial_slave_init();
47#endif
48}
49
50bool has_usb(void) {
51 USBCON |= (1 << OTGPADE); //enables VBUS pad
52 _delay_us(5);
53 return (USBSTA & (1<<VBUS)); //checks state of VBUS
54}
55
56void split_keyboard_setup(void) {
57 setup_handedness();
58
59 if (has_usb()) {
60 keyboard_master_setup();
61 } else {
62 keyboard_slave_setup();
63 }
64 sei();
65}
66
67// this code runs before the usb and keyboard is initialized
68void matrix_setup(void) {
69 split_keyboard_setup();
70}
diff --git a/keyboards/zinc/reva/split_util.h b/keyboards/zinc/reva/split_util.h
deleted file mode 100644
index 687ca19bd..000000000
--- a/keyboards/zinc/reva/split_util.h
+++ /dev/null
@@ -1,19 +0,0 @@
1#ifndef SPLIT_KEYBOARD_UTIL_H
2#define SPLIT_KEYBOARD_UTIL_H
3
4#include <stdbool.h>
5#include "eeconfig.h"
6
7#define SLAVE_I2C_ADDRESS 0x32
8
9extern volatile bool isLeftHand;
10
11// slave version of matix scan, defined in matrix.c
12void matrix_slave_scan(void);
13
14void split_keyboard_setup(void);
15bool has_usb(void);
16
17void matrix_master_OLED_init (void);
18
19#endif
diff --git a/keyboards/zinc/rules.mk b/keyboards/zinc/rules.mk
index 63a8cc8fc..36e717d60 100644
--- a/keyboards/zinc/rules.mk
+++ b/keyboards/zinc/rules.mk
@@ -27,12 +27,8 @@ AUDIO_ENABLE = no # Audio output on port C6
27UNICODE_ENABLE = no # Unicode 27UNICODE_ENABLE = no # Unicode
28BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID 28BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
29RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. 29RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
30SUBPROJECT_rev1 = no
31USE_I2C = yes
32# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
33SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend 30SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
34 31
35CUSTOM_MATRIX = yes
36 32
37DEFAULT_FOLDER = zinc/rev1 33DEFAULT_FOLDER = zinc/rev1
38 34
diff --git a/keyboards/zinc/serial.c b/keyboards/zinc/serial.c
deleted file mode 100644
index f6293c3dc..000000000
--- a/keyboards/zinc/serial.c
+++ /dev/null
@@ -1,589 +0,0 @@
1/*
2 * WARNING: be careful changing this code, it is very timing dependent
3 *
4 * 2018-10-28 checked
5 * avr-gcc 4.9.2
6 * avr-gcc 5.4.0
7 * avr-gcc 7.3.0
8 */
9
10#ifndef F_CPU
11#define F_CPU 16000000
12#endif
13
14#include <avr/io.h>
15#include <avr/interrupt.h>
16#include <util/delay.h>
17#include <stddef.h>
18#include <stdbool.h>
19#include "serial.h"
20
21#ifdef SOFT_SERIAL_PIN
22
23#ifdef __AVR_ATmega32U4__
24 // if using ATmega32U4 I2C, can not use PD0 and PD1 in soft serial.
25 #ifdef USE_I2C
26 #if SOFT_SERIAL_PIN == D0 || SOFT_SERIAL_PIN == D1
27 #error Using ATmega32U4 I2C, so can not use PD0, PD1
28 #endif
29 #endif
30
31 #if SOFT_SERIAL_PIN >= D0 && SOFT_SERIAL_PIN <= D3
32 #define SERIAL_PIN_DDR DDRD
33 #define SERIAL_PIN_PORT PORTD
34 #define SERIAL_PIN_INPUT PIND
35 #if SOFT_SERIAL_PIN == D0
36 #define SERIAL_PIN_MASK _BV(PD0)
37 #define EIMSK_BIT _BV(INT0)
38 #define EICRx_BIT (~(_BV(ISC00) | _BV(ISC01)))
39 #define SERIAL_PIN_INTERRUPT INT0_vect
40 #elif SOFT_SERIAL_PIN == D1
41 #define SERIAL_PIN_MASK _BV(PD1)
42 #define EIMSK_BIT _BV(INT1)
43 #define EICRx_BIT (~(_BV(ISC10) | _BV(ISC11)))
44 #define SERIAL_PIN_INTERRUPT INT1_vect
45 #elif SOFT_SERIAL_PIN == D2
46 #define SERIAL_PIN_MASK _BV(PD2)
47 #define EIMSK_BIT _BV(INT2)
48 #define EICRx_BIT (~(_BV(ISC20) | _BV(ISC21)))
49 #define SERIAL_PIN_INTERRUPT INT2_vect
50 #elif SOFT_SERIAL_PIN == D3
51 #define SERIAL_PIN_MASK _BV(PD3)
52 #define EIMSK_BIT _BV(INT3)
53 #define EICRx_BIT (~(_BV(ISC30) | _BV(ISC31)))
54 #define SERIAL_PIN_INTERRUPT INT3_vect
55 #endif
56 #elif SOFT_SERIAL_PIN == E6
57 #define SERIAL_PIN_DDR DDRE
58 #define SERIAL_PIN_PORT PORTE
59 #define SERIAL_PIN_INPUT PINE
60 #define SERIAL_PIN_MASK _BV(PE6)
61 #define EIMSK_BIT _BV(INT6)
62 #define EICRx_BIT (~(_BV(ISC60) | _BV(ISC61)))
63 #define SERIAL_PIN_INTERRUPT INT6_vect
64 #else
65 #error invalid SOFT_SERIAL_PIN value
66 #endif
67
68#else
69 #error serial.c now support ATmega32U4 only
70#endif
71
72//////////////// for backward compatibility ////////////////////////////////
73#ifndef SERIAL_USE_MULTI_TRANSACTION
74/* --- USE Simple API (OLD API, compatible with let's split serial.c) */
75 #if SERIAL_SLAVE_BUFFER_LENGTH > 0
76 uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};
77 #endif
78 #if SERIAL_MASTER_BUFFER_LENGTH > 0
79 uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
80 #endif
81 uint8_t volatile status0 = 0;
82
83SSTD_t transactions[] = {
84 { (uint8_t *)&status0,
85 #if SERIAL_MASTER_BUFFER_LENGTH > 0
86 sizeof(serial_master_buffer), (uint8_t *)serial_master_buffer,
87 #else
88 0, (uint8_t *)NULL,
89 #endif
90 #if SERIAL_SLAVE_BUFFER_LENGTH > 0
91 sizeof(serial_slave_buffer), (uint8_t *)serial_slave_buffer
92 #else
93 0, (uint8_t *)NULL,
94 #endif
95 }
96};
97
98void serial_master_init(void)
99{ soft_serial_initiator_init(transactions, TID_LIMIT(transactions)); }
100
101void serial_slave_init(void)
102{ soft_serial_target_init(transactions, TID_LIMIT(transactions)); }
103
104// 0 => no error
105// 1 => slave did not respond
106// 2 => checksum error
107int serial_update_buffers()
108{
109 int result;
110 result = soft_serial_transaction();
111 return result;
112}
113
114#endif // end of Simple API (OLD API, compatible with let's split serial.c)
115////////////////////////////////////////////////////////////////////////////
116
117#define ALWAYS_INLINE __attribute__((always_inline))
118#define NO_INLINE __attribute__((noinline))
119#define _delay_sub_us(x) __builtin_avr_delay_cycles(x)
120
121// parity check
122#define ODD_PARITY 1
123#define EVEN_PARITY 0
124#define PARITY EVEN_PARITY
125
126#ifdef SERIAL_DELAY
127 // custom setup in config.h
128 // #define TID_SEND_ADJUST 2
129 // #define SERIAL_DELAY 6 // micro sec
130 // #define READ_WRITE_START_ADJUST 30 // cycles
131 // #define READ_WRITE_WIDTH_ADJUST 8 // cycles
132#else
133// ============ Standard setups ============
134
135#ifndef SELECT_SOFT_SERIAL_SPEED
136#define SELECT_SOFT_SERIAL_SPEED 1
137// 0: about 189kbps
138// 1: about 137kbps (default)
139// 2: about 75kbps
140// 3: about 39kbps
141// 4: about 26kbps
142// 5: about 20kbps
143#endif
144
145#if __GNUC__ < 6
146 #define TID_SEND_ADJUST 14
147#else
148 #define TID_SEND_ADJUST 2
149#endif
150
151#if SELECT_SOFT_SERIAL_SPEED == 0
152 // Very High speed
153 #define SERIAL_DELAY 4 // micro sec
154 #if __GNUC__ < 6
155 #define READ_WRITE_START_ADJUST 33 // cycles
156 #define READ_WRITE_WIDTH_ADJUST 3 // cycles
157 #else
158 #define READ_WRITE_START_ADJUST 34 // cycles
159 #define READ_WRITE_WIDTH_ADJUST 7 // cycles
160 #endif
161#elif SELECT_SOFT_SERIAL_SPEED == 1
162 // High speed
163 #define SERIAL_DELAY 6 // micro sec
164 #if __GNUC__ < 6
165 #define READ_WRITE_START_ADJUST 30 // cycles
166 #define READ_WRITE_WIDTH_ADJUST 3 // cycles
167 #else
168 #define READ_WRITE_START_ADJUST 33 // cycles
169 #define READ_WRITE_WIDTH_ADJUST 7 // cycles
170 #endif
171#elif SELECT_SOFT_SERIAL_SPEED == 2
172 // Middle speed
173 #define SERIAL_DELAY 12 // micro sec
174 #define READ_WRITE_START_ADJUST 30 // cycles
175 #if __GNUC__ < 6
176 #define READ_WRITE_WIDTH_ADJUST 3 // cycles
177 #else
178 #define READ_WRITE_WIDTH_ADJUST 7 // cycles
179 #endif
180#elif SELECT_SOFT_SERIAL_SPEED == 3
181 // Low speed
182 #define SERIAL_DELAY 24 // micro sec
183 #define READ_WRITE_START_ADJUST 30 // cycles
184 #if __GNUC__ < 6
185 #define READ_WRITE_WIDTH_ADJUST 3 // cycles
186 #else
187 #define READ_WRITE_WIDTH_ADJUST 7 // cycles
188 #endif
189#elif SELECT_SOFT_SERIAL_SPEED == 4
190 // Very Low speed
191 #define SERIAL_DELAY 36 // micro sec
192 #define READ_WRITE_START_ADJUST 30 // cycles
193 #if __GNUC__ < 6
194 #define READ_WRITE_WIDTH_ADJUST 3 // cycles
195 #else
196 #define READ_WRITE_WIDTH_ADJUST 7 // cycles
197 #endif
198#elif SELECT_SOFT_SERIAL_SPEED == 5
199 // Ultra Low speed
200 #define SERIAL_DELAY 48 // micro sec
201 #define READ_WRITE_START_ADJUST 30 // cycles
202 #if __GNUC__ < 6
203 #define READ_WRITE_WIDTH_ADJUST 3 // cycles
204 #else
205 #define READ_WRITE_WIDTH_ADJUST 7 // cycles
206 #endif
207#else
208#error invalid SELECT_SOFT_SERIAL_SPEED value
209#endif /* SELECT_SOFT_SERIAL_SPEED */
210#endif /* SERIAL_DELAY */
211
212#define SERIAL_DELAY_HALF1 (SERIAL_DELAY/2)
213#define SERIAL_DELAY_HALF2 (SERIAL_DELAY - SERIAL_DELAY/2)
214
215#define SLAVE_INT_WIDTH_US 1
216#ifndef SERIAL_USE_MULTI_TRANSACTION
217 #define SLAVE_INT_RESPONSE_TIME SERIAL_DELAY
218#else
219 #define SLAVE_INT_ACK_WIDTH_UNIT 2
220 #define SLAVE_INT_ACK_WIDTH 4
221#endif
222
223static SSTD_t *Transaction_table = NULL;
224static uint8_t Transaction_table_size = 0;
225
226inline static void serial_delay(void) ALWAYS_INLINE;
227inline static
228void serial_delay(void) {
229 _delay_us(SERIAL_DELAY);
230}
231
232inline static void serial_delay_half1(void) ALWAYS_INLINE;
233inline static
234void serial_delay_half1(void) {
235 _delay_us(SERIAL_DELAY_HALF1);
236}
237
238inline static void serial_delay_half2(void) ALWAYS_INLINE;
239inline static
240void serial_delay_half2(void) {
241 _delay_us(SERIAL_DELAY_HALF2);
242}
243
244inline static void serial_output(void) ALWAYS_INLINE;
245inline static
246void serial_output(void) {
247 SERIAL_PIN_DDR |= SERIAL_PIN_MASK;
248}
249
250// make the serial pin an input with pull-up resistor
251inline static void serial_input_with_pullup(void) ALWAYS_INLINE;
252inline static
253void serial_input_with_pullup(void) {
254 SERIAL_PIN_DDR &= ~SERIAL_PIN_MASK;
255 SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
256}
257
258inline static uint8_t serial_read_pin(void) ALWAYS_INLINE;
259inline static
260uint8_t serial_read_pin(void) {
261 return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK);
262}
263
264inline static void serial_low(void) ALWAYS_INLINE;
265inline static
266void serial_low(void) {
267 SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK;
268}
269
270inline static void serial_high(void) ALWAYS_INLINE;
271inline static
272void serial_high(void) {
273 SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
274}
275
276void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size)
277{
278 Transaction_table = sstd_table;
279 Transaction_table_size = (uint8_t)sstd_table_size;
280 serial_output();
281 serial_high();
282}
283
284void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size)
285{
286 Transaction_table = sstd_table;
287 Transaction_table_size = (uint8_t)sstd_table_size;
288 serial_input_with_pullup();
289
290 // Enable INT0-INT3,INT6
291 EIMSK |= EIMSK_BIT;
292#if SERIAL_PIN_MASK == _BV(PE6)
293 // Trigger on falling edge of INT6
294 EICRB &= EICRx_BIT;
295#else
296 // Trigger on falling edge of INT0-INT3
297 EICRA &= EICRx_BIT;
298#endif
299}
300
301// Used by the sender to synchronize timing with the reciver.
302static void sync_recv(void) NO_INLINE;
303static
304void sync_recv(void) {
305 for (uint8_t i = 0; i < SERIAL_DELAY*5 && serial_read_pin(); i++ ) {
306 }
307 // This shouldn't hang if the target disconnects because the
308 // serial line will float to high if the target does disconnect.
309 while (!serial_read_pin());
310}
311
312// Used by the reciver to send a synchronization signal to the sender.
313static void sync_send(void) NO_INLINE;
314static
315void sync_send(void) {
316 serial_low();
317 serial_delay();
318 serial_high();
319}
320
321// Reads a byte from the serial line
322static uint8_t serial_read_chunk(uint8_t *pterrcount, uint8_t bit) NO_INLINE;
323static uint8_t serial_read_chunk(uint8_t *pterrcount, uint8_t bit) {
324 uint8_t byte, i, p, pb;
325
326 _delay_sub_us(READ_WRITE_START_ADJUST);
327 for( i = 0, byte = 0, p = PARITY; i < bit; i++ ) {
328 serial_delay_half1(); // read the middle of pulses
329 if( serial_read_pin() ) {
330 byte = (byte << 1) | 1; p ^= 1;
331 } else {
332 byte = (byte << 1) | 0; p ^= 0;
333 }
334 _delay_sub_us(READ_WRITE_WIDTH_ADJUST);
335 serial_delay_half2();
336 }
337 /* recive parity bit */
338 serial_delay_half1(); // read the middle of pulses
339 pb = serial_read_pin();
340 _delay_sub_us(READ_WRITE_WIDTH_ADJUST);
341 serial_delay_half2();
342
343 *pterrcount += (p != pb)? 1 : 0;
344
345 return byte;
346}
347
348// Sends a byte with MSB ordering
349void serial_write_chunk(uint8_t data, uint8_t bit) NO_INLINE;
350void serial_write_chunk(uint8_t data, uint8_t bit) {
351 uint8_t b, p;
352 for( p = PARITY, b = 1<<(bit-1); b ; b >>= 1) {
353 if(data & b) {
354 serial_high(); p ^= 1;
355 } else {
356 serial_low(); p ^= 0;
357 }
358 serial_delay();
359 }
360 /* send parity bit */
361 if(p & 1) { serial_high(); }
362 else { serial_low(); }
363 serial_delay();
364
365 serial_low(); // sync_send() / senc_recv() need raise edge
366}
367
368static void serial_send_packet(uint8_t *buffer, uint8_t size) NO_INLINE;
369static
370void serial_send_packet(uint8_t *buffer, uint8_t size) {
371 for (uint8_t i = 0; i < size; ++i) {
372 uint8_t data;
373 data = buffer[i];
374 sync_send();
375 serial_write_chunk(data,8);
376 }
377}
378
379static uint8_t serial_recive_packet(uint8_t *buffer, uint8_t size) NO_INLINE;
380static
381uint8_t serial_recive_packet(uint8_t *buffer, uint8_t size) {
382 uint8_t pecount = 0;
383 for (uint8_t i = 0; i < size; ++i) {
384 uint8_t data;
385 sync_recv();
386 data = serial_read_chunk(&pecount, 8);
387 buffer[i] = data;
388 }
389 return pecount == 0;
390}
391
392inline static
393void change_sender2reciver(void) {
394 sync_send(); //0
395 serial_delay_half1(); //1
396 serial_low(); //2
397 serial_input_with_pullup(); //2
398 serial_delay_half1(); //3
399}
400
401inline static
402void change_reciver2sender(void) {
403 sync_recv(); //0
404 serial_delay(); //1
405 serial_low(); //3
406 serial_output(); //3
407 serial_delay_half1(); //4
408}
409
410static inline uint8_t nibble_bits_count(uint8_t bits)
411{
412 bits = (bits & 0x5) + (bits >> 1 & 0x5);
413 bits = (bits & 0x3) + (bits >> 2 & 0x3);
414 return bits;
415}
416
417// interrupt handle to be used by the target device
418ISR(SERIAL_PIN_INTERRUPT) {
419
420#ifndef SERIAL_USE_MULTI_TRANSACTION
421 serial_low();
422 serial_output();
423 SSTD_t *trans = Transaction_table;
424#else
425 // recive transaction table index
426 uint8_t tid, bits;
427 uint8_t pecount = 0;
428 sync_recv();
429 bits = serial_read_chunk(&pecount,7);
430 tid = bits>>3;
431 bits = (bits&7) != nibble_bits_count(tid);
432 if( bits || pecount> 0 || tid > Transaction_table_size ) {
433 return;
434 }
435 serial_delay_half1();
436
437 serial_high(); // response step1 low->high
438 serial_output();
439 _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT*SLAVE_INT_ACK_WIDTH);
440 SSTD_t *trans = &Transaction_table[tid];
441 serial_low(); // response step2 ack high->low
442#endif
443
444 // target send phase
445 if( trans->target2initiator_buffer_size > 0 )
446 serial_send_packet((uint8_t *)trans->target2initiator_buffer,
447 trans->target2initiator_buffer_size);
448 // target switch to input
449 change_sender2reciver();
450
451 // target recive phase
452 if( trans->initiator2target_buffer_size > 0 ) {
453 if (serial_recive_packet((uint8_t *)trans->initiator2target_buffer,
454 trans->initiator2target_buffer_size) ) {
455 *trans->status = TRANSACTION_ACCEPTED;
456 } else {
457 *trans->status = TRANSACTION_DATA_ERROR;
458 }
459 } else {
460 *trans->status = TRANSACTION_ACCEPTED;
461 }
462
463 sync_recv(); //weit initiator output to high
464}
465
466/////////
467// start transaction by initiator
468//
469// int soft_serial_transaction(int sstd_index)
470//
471// Returns:
472// TRANSACTION_END
473// TRANSACTION_NO_RESPONSE
474// TRANSACTION_DATA_ERROR
475// this code is very time dependent, so we need to disable interrupts
476#ifndef SERIAL_USE_MULTI_TRANSACTION
477int soft_serial_transaction(void) {
478 SSTD_t *trans = Transaction_table;
479#else
480int soft_serial_transaction(int sstd_index) {
481 if( sstd_index > Transaction_table_size )
482 return TRANSACTION_TYPE_ERROR;
483 SSTD_t *trans = &Transaction_table[sstd_index];
484#endif
485 cli();
486
487 // signal to the target that we want to start a transaction
488 serial_output();
489 serial_low();
490 _delay_us(SLAVE_INT_WIDTH_US);
491
492#ifndef SERIAL_USE_MULTI_TRANSACTION
493 // wait for the target response
494 serial_input_with_pullup();
495 _delay_us(SLAVE_INT_RESPONSE_TIME);
496
497 // check if the target is present
498 if (serial_read_pin()) {
499 // target failed to pull the line low, assume not present
500 serial_output();
501 serial_high();
502 *trans->status = TRANSACTION_NO_RESPONSE;
503 sei();
504 return TRANSACTION_NO_RESPONSE;
505 }
506
507#else
508 // send transaction table index
509 int tid = (sstd_index<<3) | (7 & nibble_bits_count(sstd_index));
510 sync_send();
511 _delay_sub_us(TID_SEND_ADJUST);
512 serial_write_chunk(tid, 7);
513 serial_delay_half1();
514
515 // wait for the target response (step1 low->high)
516 serial_input_with_pullup();
517 while( !serial_read_pin() ) {
518 _delay_sub_us(2);
519 }
520
521 // check if the target is present (step2 high->low)
522 for( int i = 0; serial_read_pin(); i++ ) {
523 if (i > SLAVE_INT_ACK_WIDTH + 1) {
524 // slave failed to pull the line low, assume not present
525 serial_output();
526 serial_high();
527 *trans->status = TRANSACTION_NO_RESPONSE;
528 sei();
529 return TRANSACTION_NO_RESPONSE;
530 }
531 _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT);
532 }
533#endif
534
535 // initiator recive phase
536 // if the target is present syncronize with it
537 if( trans->target2initiator_buffer_size > 0 ) {
538 if (!serial_recive_packet((uint8_t *)trans->target2initiator_buffer,
539 trans->target2initiator_buffer_size) ) {
540 serial_output();
541 serial_high();
542 *trans->status = TRANSACTION_DATA_ERROR;
543 sei();
544 return TRANSACTION_DATA_ERROR;
545 }
546 }
547
548 // initiator switch to output
549 change_reciver2sender();
550
551 // initiator send phase
552 if( trans->initiator2target_buffer_size > 0 ) {
553 serial_send_packet((uint8_t *)trans->initiator2target_buffer,
554 trans->initiator2target_buffer_size);
555 }
556
557 // always, release the line when not in use
558 sync_send();
559
560 *trans->status = TRANSACTION_END;
561 sei();
562 return TRANSACTION_END;
563}
564
565#ifdef SERIAL_USE_MULTI_TRANSACTION
566int soft_serial_get_and_clean_status(int sstd_index) {
567 SSTD_t *trans = &Transaction_table[sstd_index];
568 cli();
569 int retval = *trans->status;
570 *trans->status = 0;;
571 sei();
572 return retval;
573}
574#endif
575
576#endif
577
578// Helix serial.c history
579// 2018-1-29 fork from let's split and add PD2, modify sync_recv() (#2308, bceffdefc)
580// 2018-6-28 bug fix master to slave comm and speed up (#3255, 1038bbef4)
581// (adjusted with avr-gcc 4.9.2)
582// 2018-7-13 remove USE_SERIAL_PD2 macro (#3374, f30d6dd78)
583// (adjusted with avr-gcc 4.9.2)
584// 2018-8-11 add support multi-type transaction (#3608, feb5e4aae)
585// (adjusted with avr-gcc 4.9.2)
586// 2018-10-21 fix serial and RGB animation conflict (#4191, 4665e4fff)
587// (adjusted with avr-gcc 7.3.0)
588// 2018-10-28 re-adjust compiler depend value of delay (#4269, 8517f8a66)
589// (adjusted with avr-gcc 5.4.0, 7.3.0)
diff --git a/keyboards/zinc/serial.h b/keyboards/zinc/serial.h
deleted file mode 100644
index 7e0c0847a..000000000
--- a/keyboards/zinc/serial.h
+++ /dev/null
@@ -1,84 +0,0 @@
1#ifndef SOFT_SERIAL_H
2#define SOFT_SERIAL_H
3
4#include <stdbool.h>
5
6// /////////////////////////////////////////////////////////////////
7// Need Soft Serial defines in config.h
8// /////////////////////////////////////////////////////////////////
9// ex.
10// #define SOFT_SERIAL_PIN ?? // ?? = D0,D1,D2,D3,E6
11// OPTIONAL: #define SELECT_SOFT_SERIAL_SPEED ? // ? = 1,2,3,4,5
12// // 1: about 137kbps (default)
13// // 2: about 75kbps
14// // 3: about 39kbps
15// // 4: about 26kbps
16// // 5: about 20kbps
17//
18// //// USE Simple API (OLD API, compatible with let's split serial.c)
19// ex.
20// #define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
21// #define SERIAL_MASTER_BUFFER_LENGTH 1
22//
23// //// USE flexible API (using multi-type transaction function)
24// #define SERIAL_USE_MULTI_TRANSACTION
25//
26// /////////////////////////////////////////////////////////////////
27
28
29#ifndef SERIAL_USE_MULTI_TRANSACTION
30/* --- USE Simple API (OLD API, compatible with let's split serial.c) */
31#if SERIAL_SLAVE_BUFFER_LENGTH > 0
32extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
33#endif
34#if SERIAL_MASTER_BUFFER_LENGTH > 0
35extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
36#endif
37
38void serial_master_init(void);
39void serial_slave_init(void);
40int serial_update_buffers(void);
41
42#endif // USE Simple API
43
44// Soft Serial Transaction Descriptor
45typedef struct _SSTD_t {
46 uint8_t *status;
47 uint8_t initiator2target_buffer_size;
48 uint8_t *initiator2target_buffer;
49 uint8_t target2initiator_buffer_size;
50 uint8_t *target2initiator_buffer;
51} SSTD_t;
52#define TID_LIMIT( table ) (sizeof(table) / sizeof(SSTD_t))
53
54// initiator is transaction start side
55void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size);
56// target is interrupt accept side
57void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size);
58
59// initiator resullt
60#define TRANSACTION_END 0
61#define TRANSACTION_NO_RESPONSE 0x1
62#define TRANSACTION_DATA_ERROR 0x2
63#define TRANSACTION_TYPE_ERROR 0x4
64#ifndef SERIAL_USE_MULTI_TRANSACTION
65int soft_serial_transaction(void);
66#else
67int soft_serial_transaction(int sstd_index);
68#endif
69
70// target status
71// *SSTD_t.status has
72// initiator:
73// TRANSACTION_END
74// or TRANSACTION_NO_RESPONSE
75// or TRANSACTION_DATA_ERROR
76// target:
77// TRANSACTION_DATA_ERROR
78// or TRANSACTION_ACCEPTED
79#define TRANSACTION_ACCEPTED 0x8
80#ifdef SERIAL_USE_MULTI_TRANSACTION
81int soft_serial_get_and_clean_status(int sstd_index);
82#endif
83
84#endif /* SOFT_SERIAL_H */
diff --git a/keyboards/zinc/zinc.h b/keyboards/zinc/zinc.h
index 87d889da0..dedc9253b 100644
--- a/keyboards/zinc/zinc.h
+++ b/keyboards/zinc/zinc.h
@@ -1,5 +1,4 @@
1#ifndef ZINC_H 1#pragma once
2#define ZINC_H
3 2
4#ifdef KEYBOARD_zinc_reva 3#ifdef KEYBOARD_zinc_reva
5 #include "reva.h" 4 #include "reva.h"
@@ -8,7 +7,4 @@
8 #include "rev1.h" 7 #include "rev1.h"
9#endif 8#endif
10 9
11
12#include "quantum.h" 10#include "quantum.h"
13
14#endif