aboutsummaryrefslogtreecommitdiff
path: root/keyboards/helix/rev1/split_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/helix/rev1/split_util.c')
-rw-r--r--keyboards/helix/rev1/split_util.c86
1 files changed, 0 insertions, 86 deletions
diff --git a/keyboards/helix/rev1/split_util.c b/keyboards/helix/rev1/split_util.c
deleted file mode 100644
index 5debd6e00..000000000
--- a/keyboards/helix/rev1/split_util.c
+++ /dev/null
@@ -1,86 +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#include "config.h"
11
12#ifdef USE_MATRIX_I2C
13# include "i2c.h"
14#else
15# include "serial.h"
16#endif
17
18volatile bool isLeftHand = true;
19
20static void setup_handedness(void) {
21 #ifdef EE_HANDS
22 isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS);
23 #else
24 // I2C_MASTER_RIGHT is deprecated, use MASTER_RIGHT instead, since this works for both serial and i2c
25 #if defined(I2C_MASTER_RIGHT) || defined(MASTER_RIGHT)
26 isLeftHand = !has_usb();
27 #else
28 isLeftHand = has_usb();
29 #endif
30 #endif
31}
32
33static void keyboard_master_setup(void) {
34#ifdef USE_I2C
35#ifdef SSD1306OLED
36 matrix_master_OLED_init ();
37#endif
38#endif
39#ifdef USE_MATRIX_I2C
40 i2c_master_init();
41#else
42 serial_master_init();
43#endif
44}
45
46static void keyboard_slave_setup(void) {
47#ifdef USE_MATRIX_I2C
48 i2c_slave_init(SLAVE_I2C_ADDRESS);
49#else
50 serial_slave_init();
51#endif
52}
53
54bool has_usb(void) {
55 USBCON |= (1 << OTGPADE); //enables VBUS pad
56 _delay_us(5);
57 return (USBSTA & (1<<VBUS)); //checks state of VBUS
58}
59
60void split_keyboard_setup(void) {
61 setup_handedness();
62
63 if (has_usb()) {
64 keyboard_master_setup();
65 } else {
66 keyboard_slave_setup();
67 }
68 sei();
69}
70
71void keyboard_slave_loop(void) {
72 matrix_init();
73
74 while (1) {
75 matrix_slave_scan();
76 }
77}
78
79// this code runs before the usb and keyboard is initialized
80void matrix_setup(void) {
81 split_keyboard_setup();
82
83 if (!has_usb()) {
84 keyboard_slave_loop();
85 }
86}