qmk_firmware/keyboards/naked60/rev1/split_util.c

71 lines
1.4 KiB
C
Raw Normal View History

[Keyboard] Add keyboard Naked60 (#6527) * Add Naked60 * readme Update * Update keyboards/naked60/rules.mk Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Updated keymaps Changed the alias. * updated rule.mk Unnecessary part was deleted and explanation was added to the boot loader. * Update keyboards/naked60/rules.mk Co-Authored-By: fauxpark <fauxpark@gmail.com> * Update keyboards/naked60/rules.mk Co-Authored-By: fauxpark <fauxpark@gmail.com> * Update keyboards/naked60/rev1/rev1.h Co-Authored-By: fauxpark <fauxpark@gmail.com> * Update keyboards/naked60/rev1/rev1.h Co-Authored-By: fauxpark <fauxpark@gmail.com> * Update keyboards/naked60/rev1/config.h Co-Authored-By: fauxpark <fauxpark@gmail.com> * Update keyboards/naked60/rev1/config.h Co-Authored-By: fauxpark <fauxpark@gmail.com> * Updated keymaps rules.mk. Cleaned up declarations in rules.mk. * Updated keymap Changed remaining aliases. * Update rev1.c Cleaned up declarations in rev1.c. * Update readme The appearance has been adjusted. * Update keyboards/naked60/keymaps/default/readme.md Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update keyboards/naked60/keymaps/default_with_nafuda/readme.md Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update keyboards/naked60/keymaps/default_with_nafuda/readme.md Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update keyboards/naked60/keymaps/salicylic/readme.md Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update keyboards/naked60/keymaps/salicylic/rules.mk Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update keyboards/naked60/keymaps/salicylic_with_nafuda/rules.mk Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update keyboards/naked60/keymaps/salicylic_with_nafuda/rules.mk Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update keyboards/naked60/keymaps/salicylic_with_setta21/rules.mk Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update keyboards/naked60/keymaps/salicylic_with_setta21/rules.mk Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update keyboards/naked60/rev1/rev1.c Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update keyboards/naked60/rules.mk Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update keyboards/naked60/rules.mk Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update keyboards/naked60/keymaps/default_with_nafuda/rules.mk Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update keyboards/naked60/keymaps/salicylic/rules.mk Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update keyboards/naked60/keymaps/default_with_nafuda/rules.mk Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update keyboards/naked60/keymaps/default_with_setta21/rules.mk Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Update keyboards/naked60/keymaps/default_with_setta21/rules.mk Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com> * Updated keymaps The appearance has been adjusted. Unnecessary rules.mk was deleted. * Update keyboards/naked60/readme.md Co-Authored-By: fauxpark <fauxpark@gmail.com> * Update readme Changed to markdown format. * Update keyboards/naked60/keymaps/default/readme.md Co-Authored-By: fauxpark <fauxpark@gmail.com> * Update keyboards/naked60/keymaps/salicylic/readme.md Co-Authored-By: fauxpark <fauxpark@gmail.com> * Update keyboards/naked60/keymaps/salicylic/readme.md Co-Authored-By: fauxpark <fauxpark@gmail.com>
2019-10-16 17:26:43 +00:00
#include <avr/io.h>
#include <avr/wdt.h>
#include <avr/power.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <avr/eeprom.h>
#include "split_util.h"
#include "matrix.h"
#include "keyboard.h"
#ifdef USE_MATRIX_I2C
# include "i2c.h"
#else
# include "split_scomm.h"
#endif
volatile bool isLeftHand = true;
static void setup_handedness(void) {
#ifdef EE_HANDS
isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS);
#else
// I2C_MASTER_RIGHT is deprecated, use MASTER_RIGHT instead, since this works for both serial and i2c
#if defined(I2C_MASTER_RIGHT) || defined(MASTER_RIGHT)
isLeftHand = !has_usb();
#else
isLeftHand = has_usb();
#endif
#endif
}
static void keyboard_master_setup(void) {
#ifdef USE_MATRIX_I2C
i2c_master_init();
#else
serial_master_init();
#endif
}
static void keyboard_slave_setup(void) {
#ifdef USE_MATRIX_I2C
i2c_slave_init(SLAVE_I2C_ADDRESS);
#else
serial_slave_init();
#endif
}
bool has_usb(void) {
USBCON |= (1 << OTGPADE); //enables VBUS pad
_delay_us(5);
return (USBSTA & (1<<VBUS)); //checks state of VBUS
}
void split_keyboard_setup(void) {
setup_handedness();
if (has_usb()) {
keyboard_master_setup();
} else {
keyboard_slave_setup();
}
sei();
}
// this code runs before the usb and keyboard is initialized
void matrix_setup(void) {
split_keyboard_setup();
}