4 #include <avr/interrupt.h>
5 #include <util/delay.h>
6 #include <avr/eeprom.h>
7 #include "split_util.h"
15 volatile bool isLeftHand = true;
17 static void setup_handedness(void) {
19 isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS);
21 // I2C_MASTER_RIGHT is deprecated, use MASTER_RIGHT instead, since this works for both serial and i2c
22 #if defined(I2C_MASTER_RIGHT) || defined(MASTER_RIGHT)
23 isLeftHand = !has_usb();
25 isLeftHand = has_usb();
30 static void keyboard_master_setup(void) {
34 matrix_master_OLED_init ();
41 static void keyboard_slave_setup(void) {
44 i2c_slave_init(SLAVE_I2C_ADDRESS);
51 /* return (UDADDR & _BV(ADDEN)); */
52 USBCON |= (1 << OTGPADE); //enables VBUS pad
54 return (USBSTA & (1<<VBUS)); //checks state of VBUS
57 void split_keyboard_setup(void) {
61 /* if (has_usb()) { */
62 keyboard_master_setup();
64 keyboard_slave_setup();
69 void keyboard_slave_loop(void) {
77 // this code runs before the usb and keyboard is initialized
78 void matrix_setup(void) {
79 split_keyboard_setup();
82 /* if (!has_usb()) { */
83 keyboard_slave_loop();