diff options
| author | Pekaso <pekaso34@gmail.com> | 2018-06-03 00:48:34 +0900 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2018-06-02 08:48:34 -0700 |
| commit | 2196dc9f868334beabd8c3585127a74bf42ce6b7 (patch) | |
| tree | ed3f7f2edbfd1b36c7082282e5cc89fb2a3892e2 /keyboards/fortitude60/split_util.c | |
| parent | 9fb1e5d171906e9f10f4489f61d456a9f29499e8 (diff) | |
| download | qmk_firmware-2196dc9f868334beabd8c3585127a74bf42ce6b7.tar.gz qmk_firmware-2196dc9f868334beabd8c3585127a74bf42ce6b7.zip | |
Add support for staggerd column layout KB "Fortitude60" (#3090)
* modifying fortitude for working
* add accurate keymap
* backlight fix
* Fix slave LED Backlight
* Add readme.md
* modified readme.md
* Fixed make error
* Commit including suggestions
* Add dvorak and colemak layout and some fix
Diffstat (limited to 'keyboards/fortitude60/split_util.c')
| -rw-r--r-- | keyboards/fortitude60/split_util.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/keyboards/fortitude60/split_util.c b/keyboards/fortitude60/split_util.c new file mode 100644 index 000000000..1adae7844 --- /dev/null +++ b/keyboards/fortitude60/split_util.c | |||
| @@ -0,0 +1,85 @@ | |||
| 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 | #include "serial.h" | ||
| 14 | |||
| 15 | volatile bool isLeftHand = true; | ||
| 16 | |||
| 17 | static void setup_handedness(void) { | ||
| 18 | #ifdef EE_HANDS | ||
| 19 | isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS); | ||
| 20 | #else | ||
| 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(); | ||
| 24 | #else | ||
| 25 | isLeftHand = has_usb(); | ||
| 26 | #endif | ||
| 27 | #endif | ||
| 28 | } | ||
| 29 | |||
| 30 | static void keyboard_master_setup(void) { | ||
| 31 | #ifdef USE_I2C | ||
| 32 | i2c_master_init(); | ||
| 33 | #ifdef SSD1306OLED | ||
| 34 | matrix_master_OLED_init (); | ||
| 35 | #endif | ||
| 36 | #else | ||
| 37 | serial_master_init(); | ||
| 38 | #endif | ||
| 39 | } | ||
| 40 | |||
| 41 | static void keyboard_slave_setup(void) { | ||
| 42 | timer_init(); | ||
| 43 | #ifdef USE_I2C | ||
| 44 | i2c_slave_init(SLAVE_I2C_ADDRESS); | ||
| 45 | #else | ||
| 46 | serial_slave_init(); | ||
| 47 | #endif | ||
| 48 | } | ||
| 49 | |||
| 50 | bool has_usb(void) { | ||
| 51 | /* return (UDADDR & _BV(ADDEN)); */ | ||
| 52 | USBCON |= (1 << OTGPADE); //enables VBUS pad | ||
| 53 | _delay_us(5); | ||
| 54 | return (USBSTA & (1<<VBUS)); //checks state of VBUS | ||
| 55 | } | ||
| 56 | |||
| 57 | void split_keyboard_setup(void) { | ||
| 58 | setup_handedness(); | ||
| 59 | |||
| 60 | if (isLeftHand) { | ||
| 61 | /* if (has_usb()) { */ | ||
| 62 | keyboard_master_setup(); | ||
| 63 | } else { | ||
| 64 | keyboard_slave_setup(); | ||
| 65 | } | ||
| 66 | sei(); | ||
| 67 | } | ||
| 68 | |||
| 69 | void keyboard_slave_loop(void) { | ||
| 70 | matrix_init(); | ||
| 71 | |||
| 72 | while (1) { | ||
| 73 | matrix_slave_scan(); | ||
| 74 | } | ||
| 75 | } | ||
| 76 | |||
| 77 | // this code runs before the usb and keyboard is initialized | ||
| 78 | void matrix_setup(void) { | ||
| 79 | split_keyboard_setup(); | ||
| 80 | |||
| 81 | if (!isLeftHand) { | ||
| 82 | /* if (!has_usb()) { */ | ||
| 83 | keyboard_slave_loop(); | ||
| 84 | } | ||
| 85 | } | ||
