diff options
| author | Len Trigg <lenbok@gmail.com> | 2018-07-26 07:16:03 +1200 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2018-07-25 12:16:03 -0700 |
| commit | 0fa192091c142a35a166930e63cdaf80bf83a229 (patch) | |
| tree | ebdf3c6b068a368a707d27f416ae293553fa50db /keyboards/redox/split_util.c | |
| parent | 4b5dcda1265fd2df7392588c6897cc881bf01929 (diff) | |
| download | qmk_firmware-0fa192091c142a35a166930e63cdaf80bf83a229.tar.gz qmk_firmware-0fa192091c142a35a166930e63cdaf80bf83a229.zip | |
redox: convert to use SPLIT_KEYBOARD feature (#3478)
Diffstat (limited to 'keyboards/redox/split_util.c')
| -rw-r--r-- | keyboards/redox/split_util.c | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/keyboards/redox/split_util.c b/keyboards/redox/split_util.c deleted file mode 100644 index 346cbc908..000000000 --- a/keyboards/redox/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 | #include "timer.h" | ||
| 12 | |||
| 13 | #ifdef USE_I2C | ||
| 14 | # include "i2c.h" | ||
| 15 | #else | ||
| 16 | # include "serial.h" | ||
| 17 | #endif | ||
| 18 | |||
| 19 | volatile bool isLeftHand = true; | ||
| 20 | |||
| 21 | static void setup_handedness(void) { | ||
| 22 | #ifdef EE_HANDS | ||
| 23 | isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS); | ||
| 24 | #else | ||
| 25 | // I2C_MASTER_RIGHT is deprecated, use MASTER_RIGHT instead, since this works for both serial and i2c | ||
| 26 | #if defined(I2C_MASTER_RIGHT) || defined(MASTER_RIGHT) | ||
| 27 | isLeftHand = !has_usb(); | ||
| 28 | #else | ||
| 29 | isLeftHand = has_usb(); | ||
| 30 | #endif | ||
| 31 | #endif | ||
| 32 | } | ||
| 33 | |||
| 34 | static void keyboard_master_setup(void) { | ||
| 35 | #ifdef USE_I2C | ||
| 36 | i2c_master_init(); | ||
| 37 | #ifdef SSD1306OLED | ||
| 38 | matrix_master_OLED_init (); | ||
| 39 | #endif | ||
| 40 | #else | ||
| 41 | serial_master_init(); | ||
| 42 | #endif | ||
| 43 | } | ||
| 44 | |||
| 45 | static void keyboard_slave_setup(void) { | ||
| 46 | timer_init(); | ||
| 47 | #ifdef USE_I2C | ||
| 48 | i2c_slave_init(SLAVE_I2C_ADDRESS); | ||
| 49 | #else | ||
| 50 | serial_slave_init(); | ||
| 51 | #endif | ||
| 52 | } | ||
| 53 | |||
| 54 | bool 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 | |||
| 60 | void 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 | |||
| 71 | void 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 | ||
| 80 | void matrix_setup(void) { | ||
| 81 | split_keyboard_setup(); | ||
| 82 | |||
| 83 | if (!has_usb()) { | ||
| 84 | keyboard_slave_loop(); | ||
| 85 | } | ||
| 86 | } | ||
