Skip to content

Commit e06fde6

Browse files
firetechnhongooi
authored andcommitted
Switch Ergodox Infinity over to split_common (qmk#13481)
1 parent 6bd37bf commit e06fde6

File tree

7 files changed

+36
-323
lines changed

7 files changed

+36
-323
lines changed

keyboards/ergodox_infinity/config.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
5454
/* key matrix size */
5555
#define MATRIX_ROWS 18
5656
#define MATRIX_COLS 5
57-
#define LOCAL_MATRIX_ROWS 9
57+
58+
// For some reason, the rows are colums in the schematic, and vice versa
59+
#define MATRIX_ROW_PINS { B2, B3, B18, B19, C0, C9, C10, C11, D0 }
60+
#define MATRIX_COL_PINS { D1, D4, D5, D6, D7 }
61+
#define UNUSED_PINS
62+
63+
/* COL2ROW, ROW2COL */
64+
#define DIODE_DIRECTION ROW2COL
65+
66+
/* Serial config (for communication between halves) */
67+
#define SERIAL_USART_DRIVER SD1 // Only true for the master half
68+
#define SERIAL_USART_CONFIG { (SERIAL_USART_SPEED), } // Only field is speed
69+
#define SERIAL_USART_FULL_DUPLEX
70+
#define SERIAL_USART_TIMEOUT 50
5871

5972
/* number of backlight levels */
6073
#define BACKLIGHT_LEVELS 3
@@ -103,10 +116,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
103116
/* Set 0 if debouncing isn't needed */
104117
#define DEBOUNCE 5
105118

106-
#define SERIAL_LINK_BAUD 562500
107-
#define SERIAL_LINK_THREAD_PRIORITY (NORMALPRIO - 1)
108-
109119
#define VISUALIZER_USER_DATA_SIZE 16
120+
110121
/*
111122
* Feature disable options
112123
* These options are also useful to firmware size reduction.

keyboards/ergodox_infinity/ergodox_infinity.c

Lines changed: 16 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,6 @@
88
# include "lcd_backlight.h"
99
#endif
1010

11-
#if (defined(LED_MATRIX_ENABLE) || defined(WPM_ENABLE))
12-
# include "serial_link/protocol/transport.h"
13-
14-
# ifdef LED_MATRIX_ENABLE
15-
MASTER_TO_ALL_SLAVES_OBJECT(led_matrix, led_eeconfig_t);
16-
MASTER_TO_ALL_SLAVES_OBJECT(led_suspend_state, bool);
17-
static led_eeconfig_t last_sent_led_matrix;
18-
static uint16_t led_matrix_sent_timer = 0;
19-
20-
void send_led_suspend_state(void) {
21-
if (is_serial_link_master()) {
22-
*begin_write_led_suspend_state() = led_matrix_get_suspend_state();
23-
end_write_led_suspend_state();
24-
}
25-
}
26-
# endif
27-
28-
# ifdef WPM_ENABLE
29-
# include "wpm.h"
30-
MASTER_TO_ALL_SLAVES_OBJECT(current_wpm, uint8_t);
31-
static uint8_t last_sent_wpm = 0;
32-
# endif
33-
34-
static remote_object_t *remote_objects[] = {
35-
# ifdef LED_MATRIX_ENABLE
36-
REMOTE_OBJECT(led_matrix),
37-
REMOTE_OBJECT(led_suspend_state),
38-
# endif
39-
# ifdef WPM_ENABLE
40-
REMOTE_OBJECT(current_wpm),
41-
# endif
42-
};
43-
#endif
44-
45-
void init_serial_link_hal(void) {
46-
PORTA->PCR[1] = PORTx_PCRn_PE | PORTx_PCRn_PS | PORTx_PCRn_PFE | PORTx_PCRn_MUX(2);
47-
PORTA->PCR[2] = PORTx_PCRn_DSE | PORTx_PCRn_SRE | PORTx_PCRn_MUX(2);
48-
PORTE->PCR[0] = PORTx_PCRn_PE | PORTx_PCRn_PS | PORTx_PCRn_PFE | PORTx_PCRn_MUX(3);
49-
PORTE->PCR[1] = PORTx_PCRn_DSE | PORTx_PCRn_SRE | PORTx_PCRn_MUX(3);
50-
}
51-
5211
#define RED_PIN 1
5312
#define GREEN_PIN 2
5413
#define BLUE_PIN 3
@@ -176,70 +135,15 @@ void matrix_init_kb(void) {
176135
#endif
177136

178137
matrix_init_user();
179-
#if (defined(LED_MATRIX_ENABLE) || defined(WPM_ENABLE))
180-
add_remote_objects(remote_objects, sizeof(remote_objects) / sizeof(remote_object_t *));
181-
#endif
182138
}
183139

184140
void matrix_scan_kb(void) {
185141
// put your looping keyboard code here
186142
// runs every cycle (a lot)
187143

188-
#ifdef LED_MATRIX_ENABLE
189-
if (is_serial_link_master()) {
190-
if (!led_matrix_get_suspend_state()) {
191-
if (timer_elapsed(led_matrix_sent_timer) >= 5000 || memcmp((void *)&last_sent_led_matrix, (void *)&led_matrix_eeconfig, sizeof(last_sent_led_matrix))) {
192-
led_matrix_sent_timer = timer_read();
193-
memcpy((void *)&last_sent_led_matrix, (void *)&led_matrix_eeconfig, sizeof(last_sent_led_matrix));
194-
*begin_write_led_matrix() = last_sent_led_matrix;
195-
end_write_led_matrix();
196-
}
197-
}
198-
} else if (is_serial_link_connected()) {
199-
bool *new_led_suspend_state = read_led_suspend_state();
200-
if (new_led_suspend_state) {
201-
led_matrix_set_suspend_state(*new_led_suspend_state);
202-
}
203-
if (!led_matrix_get_suspend_state()) {
204-
led_eeconfig_t *new_led_matrix = read_led_matrix();
205-
if (new_led_matrix) {
206-
memcpy((void *)&led_matrix_eeconfig, (void *)new_led_matrix, sizeof(last_sent_led_matrix));
207-
}
208-
}
209-
}
210-
#endif
211-
212-
#ifdef WPM_ENABLE
213-
if (is_serial_link_master()) {
214-
uint8_t current_wpm = get_current_wpm();
215-
if (current_wpm != last_sent_wpm) {
216-
*begin_write_current_wpm() = current_wpm;
217-
end_write_current_wpm();
218-
last_sent_wpm = current_wpm;
219-
}
220-
} else if (is_serial_link_connected()) {
221-
uint8_t *new_wpm = read_current_wpm();
222-
if (new_wpm) {
223-
set_current_wpm(*new_wpm);
224-
}
225-
}
226-
#endif
227-
228144
matrix_scan_user();
229145
}
230146

231-
bool is_keyboard_master(void) { return is_serial_link_master(); }
232-
233-
bool is_keyboard_left(void) {
234-
#if defined(EE_HANDS)
235-
return eeconfig_read_handedness();
236-
#elif defined(MASTER_IS_ON_RIGHT)
237-
return !is_keyboard_master();
238-
#else
239-
return is_keyboard_master();
240-
#endif
241-
}
242-
243147
__attribute__ ((weak)) void ergodox_board_led_on(void) {}
244148

245149
__attribute__ ((weak)) void ergodox_right_led_1_on(void) {}
@@ -262,20 +166,6 @@ __attribute__ ((weak)) void ergodox_right_led_2_set(uint8_t n) {}
262166

263167
__attribute__ ((weak)) void ergodox_right_led_3_set(uint8_t n) {}
264168

265-
void suspend_power_down_kb(void) {
266-
#ifdef LED_MATRIX_ENABLE
267-
send_led_suspend_state();
268-
#endif
269-
suspend_power_down_user();
270-
}
271-
272-
void suspend_wakeup_init_kb(void) {
273-
#ifdef LED_MATRIX_ENABLE
274-
send_led_suspend_state();
275-
#endif
276-
suspend_wakeup_init_user();
277-
}
278-
279169
#ifdef SWAP_HANDS_ENABLE
280170
__attribute__ ((weak))
281171
const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
@@ -472,3 +362,19 @@ __attribute__((weak)) void st7565_task_user(void) {
472362
}
473363
}
474364
#endif
365+
366+
#if defined(SPLIT_KEYBOARD)
367+
void usart_master_init(SerialDriver **driver) {
368+
PORTA->PCR[1] = PORTx_PCRn_PE | PORTx_PCRn_PS | PORTx_PCRn_PFE | PORTx_PCRn_MUX(2);
369+
PORTA->PCR[2] = PORTx_PCRn_DSE | PORTx_PCRn_SRE | PORTx_PCRn_MUX(2);
370+
371+
// driver is set to SD1 in config.h
372+
}
373+
374+
void usart_slave_init(SerialDriver **driver) {
375+
PORTE->PCR[0] = PORTx_PCRn_PE | PORTx_PCRn_PS | PORTx_PCRn_PFE | PORTx_PCRn_MUX(3);
376+
PORTE->PCR[1] = PORTx_PCRn_DSE | PORTx_PCRn_SRE | PORTx_PCRn_MUX(3);
377+
378+
*driver = &SD2;
379+
}
380+
#endif

keyboards/ergodox_infinity/led.c

Lines changed: 0 additions & 26 deletions
This file was deleted.

keyboards/ergodox_infinity/matrix.c

Lines changed: 0 additions & 172 deletions
This file was deleted.

0 commit comments

Comments
 (0)