To follow convention.
--- /dev/null
+SUBPROJECT_DEFAULT = v2
+
+ifndef MAKEFILE_INCLUDED
+ include ../../Makefile
+endif
--- /dev/null
+ifndef MAKEFILE_INCLUDED
+ include ../../Makefile
+endif
\ No newline at end of file
--- /dev/null
+#include "DeltaSplit75.h"\r
+\r
+#ifdef AUDIO_ENABLE\r
+ float tone_startup[][2] = SONG(STARTUP_SOUND);\r
+ float tone_goodbye[][2] = SONG(GOODBYE_SOUND);\r
+#endif\r
+\r
+void matrix_init_kb(void) {\r
+\r
+ #ifdef AUDIO_ENABLE\r
+ _delay_ms(20); // gets rid of tick\r
+ PLAY_NOTE_ARRAY(tone_startup, false, 0);\r
+ #endif\r
+\r
+ // // green led on\r
+ // DDRD |= (1<<5);\r
+ // PORTD &= ~(1<<5);\r
+\r
+ // // orange led on\r
+ // DDRB |= (1<<0);\r
+ // PORTB &= ~(1<<0);\r
+\r
+ matrix_init_user();\r
+};\r
+\r
+void shutdown_user(void) {\r
+ #ifdef AUDIO_ENABLE\r
+ PLAY_NOTE_ARRAY(tone_goodbye, false, 0);\r
+ _delay_ms(150);\r
+ stop_all_notes();\r
+ #endif\r
+}\r
--- /dev/null
+#ifndef ProtoSplit_H\r
+#define ProtoSplit_H\r
+\r
+#include "../DeltaSplit75.h"\r
+\r
+//void promicro_bootloader_jmp(bool program);\r
+#include "quantum.h"\r
+\r
+//void promicro_bootloader_jmp(bool program);\r
+//matrix is defined in a weird way here; the layout on both sides are asymmetrical, but the "matrix" is symmetrical but with empty gaps\r
+//the last column is defined as a separate row because the firmware currently doesnt support more than 8 columns (this layout has 9 columns per side) K45 and K110 are the Bs on both sides\r
+#define KEYMAP( \\r
+ K00, K01, K02, K03, K04, K05, K06, K70, K71, K72, K73, K74, K75, K76, K77, K132, \\r
+ K10, K11, K12, K13, K14, K15, K16, K80, K81, K82, K83, K84, K85, K86, K87, K133, \\r
+ K20, K21, K22, K23, K24, K25, K90, K91, K92, K93, K94, K95, K96, K97, K134, \\r
+ K30, K31, K32, K33, K34, K35, K100, K101, K102, K103, K104, K105, K107, K135, \\r
+ K40, K41, K42, K43, K44, K45, K110, K111, K112, K113, K114, K115, K116, K117, K136, \\r
+ K50, K51, K52, K54, K55, K120, K121, K122, K123, K126, K127, K137 \\r
+ ) \\r
+ { \\r
+ { K00, K01, K02, K03, K04, K05, K06, KC_NO}, \\r
+ { K10, K11, K12, K13, K14, K15, K16, KC_NO}, \\r
+ { K20, K21, K22, K23, K24, K25, KC_NO, KC_NO}, \\r
+ { K30, K31, K32, K33, K34, K35, KC_NO, KC_NO}, \\r
+ { K40, K41, K42, K43, K44, K45, KC_NO, KC_NO}, \\r
+ { K50, K51, K52, KC_NO, K54, K55, KC_NO, KC_NO}, \\r
+ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO}, \\r
+ { K70 , K71, K72, K73, K74, K75, K76, K77}, \\r
+ { K80, K81, K82, K83, K84, K85, K86, K87}, \\r
+ { K90, K91, K92, K93, K94, K95, K96, K97}, \\r
+ { K100, K101, K102, K103, K104, K105, KC_NO, K107}, \\r
+ { K110, K111, K112, K113, K114, K115, K116, K117}, \\r
+ { K120, K121, K122, K123, KC_NO, KC_NO, K126, K127}, \\r
+ { KC_NO, KC_NO, K132, K133, K134, K135, K136, K137} \\r
+ }\r
+\r
+#endif
\ No newline at end of file
--- /dev/null
+/*\r
+Copyright 2012 Jun Wako <wakojun@gmail.com>\r
+\r
+This program is free software: you can redistribute it and/or modify\r
+it under the terms of the GNU General Public License as published by\r
+the Free Software Foundation, either version 2 of the License, or\r
+(at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License\r
+along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+*/\r
+\r
+#ifndef CONFIG_H\r
+#define CONFIG_H\r
+\r
+#include "config_common.h"\r
+\r
+/* USB Device descriptor parameter */\r
+#define VENDOR_ID 0xFEED\r
+#define PRODUCT_ID 0x3060\r
+#define DEVICE_VER 0x0001\r
+#define MANUFACTURER xyxjj\r
+#define PRODUCT DeltaSplit75\r
+#define DESCRIPTION 75% split keyboard\r
+\r
+/* key matrix size */\r
+// Rows are doubled-up\r
+#define MATRIX_ROWS 14\r
+#define MATRIX_COLS 8\r
+\r
+// wiring of each half\r
+#define MATRIX_ROW_PINS { F4, F5, F6, F7, B1, B3, B2 }\r
+#define MATRIX_COL_PINS { B6, B5, B4, E6, D7, C6, D4, D1}\r
+\r
+#define CATERINA_BOOTLOADER\r
+\r
+/* COL2ROW or ROW2COL */\r
+#define DIODE_DIRECTION COL2ROW\r
+\r
+/* define if matrix has ghost */\r
+//#define MATRIX_HAS_GHOST\r
+\r
+/* number of backlight levels */\r
+// #define BACKLIGHT_LEVELS 3\r
+\r
+/* Set 0 if debouncing isn't needed */\r
+#define DEBOUNCING_DELAY 5\r
+\r
+/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */\r
+#define LOCKING_SUPPORT_ENABLE\r
+/* Locking resynchronize hack */\r
+#define LOCKING_RESYNC_ENABLE\r
+\r
+/* key combination for command */\r
+#define IS_COMMAND() ( \\r
+ keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \\r
+)\r
+\r
+/* ws2812 RGB LED */\r
+#define RGB_DI_PIN D3\r
+#define RGBLIGHT_TIMER\r
+#define RGBLED_NUM 12 // Number of LEDs\r
+#define ws2812_PORTREG PORTD\r
+#define ws2812_DDRREG DDRD\r
+\r
+/*\r
+ * Feature disable options\r
+ * These options are also useful to firmware size reduction.\r
+ */\r
+\r
+/* disable debug print */\r
+// #define NO_DEBUG\r
+\r
+/* disable print */\r
+// #define NO_PRINT\r
+\r
+/* disable action features */\r
+//#define NO_ACTION_LAYER\r
+//#define NO_ACTION_TAPPING\r
+//#define NO_ACTION_ONESHOT\r
+//#define NO_ACTION_MACRO\r
+//#define NO_ACTION_FUNCTION\r
+\r
+\r
+#endif
\ No newline at end of file
--- /dev/null
+BACKLIGHT_ENABLE = no
+
+ifndef QUANTUM_DIR
+ include ../../../Makefile
+endif
--- /dev/null
+/*\r
+Copyright 2012 Jun Wako <wakojun@gmail.com>\r
+\r
+This program is free software: you can redistribute it and/or modify\r
+it under the terms of the GNU General Public License as published by\r
+the Free Software Foundation, either version 2 of the License, or\r
+(at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License\r
+along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+*/\r
+\r
+#ifndef CONFIG_H\r
+#define CONFIG_H\r
+\r
+#include "config_common.h"\r
+\r
+#ifdef SUBPROJECT_RightB\r
+ #include "RightB/config.h"\r
+#endif\r
+#ifdef SUBPROJECT_V2\r
+ #include "v2/config.h"\r
+#endif\r
+#endif\r
--- /dev/null
+#include "deltasplit75.h"
\ No newline at end of file
--- /dev/null
+#ifndef deltasplit75_H\r
+#define deltasplit75_H\r
+\r
+#ifdef SUBPROJECT_v2\r
+ #include "v2.h"\r
+#endif\r
+#ifdef SUBPROJECT_ProtoSplit\r
+ #include "ProtoSplit.h"\r
+#endif\r
+\r
+#include "quantum.h"\r
+\r
+#endif
\ No newline at end of file
--- /dev/null
+:0B0000000000000000000000000001F4\r
+:00000001FF\r
--- /dev/null
+:0B0000000000000000000000000000F5\r
+:00000001FF\r
--- /dev/null
+#include <util/twi.h>\r
+#include <avr/io.h>\r
+#include <stdlib.h>\r
+#include <avr/interrupt.h>\r
+#include <util/twi.h>\r
+#include <stdbool.h>\r
+#include "i2c.h"\r
+\r
+#ifdef USE_I2C\r
+\r
+// Limits the amount of we wait for any one i2c transaction.\r
+// Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is\r
+// 9 bits, a single transaction will take around 90μs to complete.\r
+//\r
+// (F_CPU/SCL_CLOCK) => # of μC cycles to transfer a bit\r
+// poll loop takes at least 8 clock cycles to execute\r
+#define I2C_LOOP_TIMEOUT (9+1)*(F_CPU/SCL_CLOCK)/8\r
+\r
+#define BUFFER_POS_INC() (slave_buffer_pos = (slave_buffer_pos+1)%SLAVE_BUFFER_SIZE)\r
+\r
+volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];\r
+\r
+static volatile uint8_t slave_buffer_pos;\r
+static volatile bool slave_has_register_set = false;\r
+\r
+// Wait for an i2c operation to finish\r
+inline static\r
+void i2c_delay(void) {\r
+ uint16_t lim = 0;\r
+ while(!(TWCR & (1<<TWINT)) && lim < I2C_LOOP_TIMEOUT)\r
+ lim++;\r
+\r
+ // easier way, but will wait slightly longer\r
+ // _delay_us(100);\r
+}\r
+\r
+// Setup twi to run at 100kHz\r
+void i2c_master_init(void) {\r
+ // no prescaler\r
+ TWSR = 0;\r
+ // Set TWI clock frequency to SCL_CLOCK. Need TWBR>10.\r
+ // Check datasheets for more info.\r
+ TWBR = ((F_CPU/SCL_CLOCK)-16)/2;\r
+}\r
+\r
+// Start a transaction with the given i2c slave address. The direction of the\r
+// transfer is set with I2C_READ and I2C_WRITE.\r
+// returns: 0 => success\r
+// 1 => error\r
+uint8_t i2c_master_start(uint8_t address) {\r
+ TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTA);\r
+\r
+ i2c_delay();\r
+\r
+ // check that we started successfully\r
+ if ( (TW_STATUS != TW_START) && (TW_STATUS != TW_REP_START))\r
+ return 1;\r
+\r
+ TWDR = address;\r
+ TWCR = (1<<TWINT) | (1<<TWEN);\r
+\r
+ i2c_delay();\r
+\r
+ if ( (TW_STATUS != TW_MT_SLA_ACK) && (TW_STATUS != TW_MR_SLA_ACK) )\r
+ return 1; // slave did not acknowledge\r
+ else\r
+ return 0; // success\r
+}\r
+\r
+\r
+// Finish the i2c transaction.\r
+void i2c_master_stop(void) {\r
+ TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);\r
+\r
+ uint16_t lim = 0;\r
+ while(!(TWCR & (1<<TWSTO)) && lim < I2C_LOOP_TIMEOUT)\r
+ lim++;\r
+}\r
+\r
+// Write one byte to the i2c slave.\r
+// returns 0 => slave ACK\r
+// 1 => slave NACK\r
+uint8_t i2c_master_write(uint8_t data) {\r
+ TWDR = data;\r
+ TWCR = (1<<TWINT) | (1<<TWEN);\r
+\r
+ i2c_delay();\r
+\r
+ // check if the slave acknowledged us\r
+ return (TW_STATUS == TW_MT_DATA_ACK) ? 0 : 1;\r
+}\r
+\r
+// Read one byte from the i2c slave. If ack=1 the slave is acknowledged,\r
+// if ack=0 the acknowledge bit is not set.\r
+// returns: byte read from i2c device\r
+uint8_t i2c_master_read(int ack) {\r
+ TWCR = (1<<TWINT) | (1<<TWEN) | (ack<<TWEA);\r
+\r
+ i2c_delay();\r
+ return TWDR;\r
+}\r
+\r
+void i2c_reset_state(void) {\r
+ TWCR = 0;\r
+}\r
+\r
+void i2c_slave_init(uint8_t address) {\r
+ TWAR = address << 0; // slave i2c address\r
+ // TWEN - twi enable\r
+ // TWEA - enable address acknowledgement\r
+ // TWINT - twi interrupt flag\r
+ // TWIE - enable the twi interrupt\r
+ TWCR = (1<<TWIE) | (1<<TWEA) | (1<<TWINT) | (1<<TWEN);\r
+}\r
+\r
+ISR(TWI_vect);\r
+\r
+ISR(TWI_vect) {\r
+ uint8_t ack = 1;\r
+ switch(TW_STATUS) {\r
+ case TW_SR_SLA_ACK:\r
+ // this device has been addressed as a slave receiver\r
+ slave_has_register_set = false;\r
+ break;\r
+\r
+ case TW_SR_DATA_ACK:\r
+ // this device has received data as a slave receiver\r
+ // The first byte that we receive in this transaction sets the location\r
+ // of the read/write location of the slaves memory that it exposes over\r
+ // i2c. After that, bytes will be written at slave_buffer_pos, incrementing\r
+ // slave_buffer_pos after each write.\r
+ if(!slave_has_register_set) {\r
+ slave_buffer_pos = TWDR;\r
+ // don't acknowledge the master if this memory loctaion is out of bounds\r
+ if ( slave_buffer_pos >= SLAVE_BUFFER_SIZE ) {\r
+ ack = 0;\r
+ slave_buffer_pos = 0;\r
+ }\r
+ slave_has_register_set = true;\r
+ } else {\r
+ i2c_slave_buffer[slave_buffer_pos] = TWDR;\r
+ BUFFER_POS_INC();\r
+ }\r
+ break;\r
+\r
+ case TW_ST_SLA_ACK:\r
+ case TW_ST_DATA_ACK:\r
+ // master has addressed this device as a slave transmitter and is\r
+ // requesting data.\r
+ TWDR = i2c_slave_buffer[slave_buffer_pos];\r
+ BUFFER_POS_INC();\r
+ break;\r
+\r
+ case TW_BUS_ERROR: // something went wrong, reset twi state\r
+ TWCR = 0;\r
+ default:\r
+ break;\r
+ }\r
+ // Reset everything, so we are ready for the next TWI interrupt\r
+ TWCR |= (1<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN);\r
+}\r
+#endif\r
--- /dev/null
+#ifndef I2C_H\r
+#define I2C_H\r
+\r
+#include <stdint.h>\r
+\r
+#ifndef F_CPU\r
+#define F_CPU 16000000UL\r
+#endif\r
+\r
+#define I2C_READ 1\r
+#define I2C_WRITE 0\r
+\r
+#define I2C_ACK 1\r
+#define I2C_NACK 0\r
+\r
+#define SLAVE_BUFFER_SIZE 0x10\r
+\r
+// i2c SCL clock frequency\r
+#define SCL_CLOCK 100000L\r
+\r
+extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];\r
+\r
+void i2c_master_init(void);\r
+uint8_t i2c_master_start(uint8_t address);\r
+void i2c_master_stop(void);\r
+uint8_t i2c_master_write(uint8_t data);\r
+uint8_t i2c_master_read(int);\r
+void i2c_reset_state(void);\r
+void i2c_slave_init(uint8_t address);\r
+\r
+#endif\r
--- /dev/null
+/*\r
+Copyright 2012 Jun Wako <wakojun@gmail.com>\r
+\r
+This program is free software: you can redistribute it and/or modify\r
+it under the terms of the GNU General Public License as published by\r
+the Free Software Foundation, either version 2 of the License, or\r
+(at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License\r
+along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+*/\r
+\r
+\r
+#define USE_SERIAL\r
+\r
+#define MASTER_LEFT\r
+// #define _MASTER_RIGHT\r
+// #define EE_HANDS\r
+\r
+\r
+#ifdef SUBPROJECT_v2\r
+ #include "../../v2/config.h"\r
+#endif\r
+#ifdef SUBPROJECT_ProtoSplit\r
+ #include "../../ProtoSplit/config.h"\r
+#endif\r
--- /dev/null
+#include "deltasplit75.h"\r
+#include "action_layer.h"\r
+#include "eeconfig.h"\r
+\r
+extern keymap_config_t keymap_config;\r
+\r
+// Each layer gets a name for readability, which is then used in the keymap matrix below.\r
+// The underscores don't mean anything - you can have a layer called STUFF or any other name.\r
+// Layer names don't all need to be of the same length, obviously, and you can also skip them\r
+// entirely and just use numbers.\r
+\r
+// Fillers to make layering more clear\r
+\r
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { \r
+ KEYMAP(\r
+ KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_INS, KC_HOME, KC_PGUP, \r
+ KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_DEL, KC_END, KC_PGDN, \r
+ KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSPC, KC_SLCK, \r
+ KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_TRNS, KC_ENT, KC_PAUS, //modify KC_TRNS to enable ISO Support\r
+ KC_LSFT, KC_TRNS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_LSFT, KC_UP, KC_PSCR, //modify KC_TRNS to enable ISO Support\r
+ KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(1), KC_SPC, KC_RALT, KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),\r
+\r
+ KEYMAP(\r
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET, \r
+ KC_BSLS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \r
+ KC_TRNS, KC_VOLU, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \r
+ M(1), KC_LEFT, KC_DOWN, KC_RGHT, KC_PAUS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \r
+ KC_TRNS, KC_TRNS, KC_VOLD, M(0), KC_PSCR, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \r
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),\r
+\r
+};
\ No newline at end of file
--- /dev/null
+/*\r
+Copyright 2012 Jun Wako <wakojun@gmail.com>\r
+\r
+This program is free software: you can redistribute it and/or modify\r
+it under the terms of the GNU General Public License as published by\r
+the Free Software Foundation, either version 2 of the License, or\r
+(at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License\r
+along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+*/\r
+\r
+\r
+#define USE_SERIAL\r
+\r
+#define MASTER_LEFT\r
+// #define _MASTER_RIGHT\r
+// #define EE_HANDS\r
+\r
+\r
+#ifdef SUBPROJECT_V2\r
+ #include "../../V2/config.h"\r
+#endif\r
+#ifdef SUBPROJECT_ProtoSplit\r
+ #include "../../ProtoSplit/config.h"\r
+#endif\r
--- /dev/null
+#include "DeltaSplit75.h"\r
+#include "action_layer.h"\r
+#include "eeconfig.h"\r
+\r
+extern keymap_config_t keymap_config;\r
+\r
+// Each layer gets a name for readability, which is then used in the keymap matrix below.\r
+// The underscores don't mean anything - you can have a layer called STUFF or any other name.\r
+// Layer names don't all need to be of the same length, obviously, and you can also skip them\r
+// entirely and just use numbers.\r
+\r
+// Fillers to make layering more clear\r
+\r
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { \r
+ KEYMAP(\r
+ KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_INS, KC_HOME, KC_PGUP, \r
+ KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_DEL, KC_END, KC_PGDN, \r
+ KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSPC, KC_SLCK, \r
+ KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PAUS,\r
+ KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_LSFT, KC_UP, KC_PSCR,\r
+ KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(1), KC_SPC, KC_RALT, KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),\r
+\r
+ KEYMAP(\r
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET, \r
+ KC_BSLS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \r
+ KC_TRNS, KC_VOLU, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \r
+ M(1), KC_LEFT, KC_DOWN, KC_RGHT, KC_PAUS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \r
+ KC_TRNS, KC_VOLD, M(0), KC_PSCR, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \r
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),\r
+\r
+};
\ No newline at end of file
-/*
-Copyright 2012 Jun Wako <wakojun@gmail.com>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-
-#define USE_SERIAL
-
-#define MASTER_LEFT
-// #define _MASTER_RIGHT
-// #define EE_HANDS
-
-
-#ifdef SUBPROJECT_v2
- #include "../../v2/config.h"
-#endif
-#ifdef SUBPROJECT_ProtoSplit
- #include "../../ProtoSplit/config.h"
-#endif
+/*\r
+Copyright 2012 Jun Wako <wakojun@gmail.com>\r
+\r
+This program is free software: you can redistribute it and/or modify\r
+it under the terms of the GNU General Public License as published by\r
+the Free Software Foundation, either version 2 of the License, or\r
+(at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License\r
+along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+*/\r
+\r
+\r
+#define USE_SERIAL\r
+\r
+#define MASTER_LEFT\r
+// #define _MASTER_RIGHT\r
+// #define EE_HANDS\r
+\r
+\r
+#ifdef SUBPROJECT_v2\r
+ #include "../../v2/config.h"\r
+#endif\r
+#ifdef SUBPROJECT_ProtoSplit\r
+ #include "../../ProtoSplit/config.h"\r
+#endif\r
-#include "deltasplit75.h"
-#include "action_layer.h"
-#include "eeconfig.h"
-
-extern keymap_config_t keymap_config;
-
-// Each layer gets a name for readability, which is then used in the keymap matrix below.
-// The underscores don't mean anything - you can have a layer called STUFF or any other name.
-// Layer names don't all need to be of the same length, obviously, and you can also skip them
-// entirely and just use numbers.
-
-// Fillers to make layering more clear
-
-const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
- /* Layer 0: Default Layer
- *,-----------------------------------------------------------------------.
- * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9| F10| F11| F12|Prnt|Ins|Del|
- * |----------------------------------------------------------------------|
- * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| Bakspace | Home|
- * |----------------------------------------------------------------------|
- * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| PgUp|
- * |----------------------------------------------------------------------|
- * |Ctrl| A| S| D| F| G| H| J| K| L| ;| '|Enter | PgDown|
- * |----------------------------------------------------------------------|
- * |Shif| | Z| X| C| V| B| N| M| ,| .| /|Shift | Up| End|
- * |----------------------------------------------------------------------|
- * |CapsLo|Gui |Alt |Sp |Mod | Sp| Alt| Gui| Ctrl| | Lef| Dow| Rig|
- * `----------------------------------------------------------------------'
- */
- KEYMAP(
- KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_INS, KC_DEL,
- KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_BSPC, KC_HOME,
- KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGUP,
- KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_TRNS, KC_ENT, KC_PGDN,
- KC_LSFT, KC_TRNS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END,
- KC_CAPS, KC_LGUI, KC_LALT, KC_SPC, MO(1), KC_SPC, KC_RALT, KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
-
- KEYMAP(
- RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET,
- RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_VOLU,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY, KC_VOLD,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_STOP, KC_MNXT),
-
+#include "deltasplit75.h"\r
+#include "action_layer.h"\r
+#include "eeconfig.h"\r
+\r
+extern keymap_config_t keymap_config;\r
+\r
+// Each layer gets a name for readability, which is then used in the keymap matrix below.\r
+// The underscores don't mean anything - you can have a layer called STUFF or any other name.\r
+// Layer names don't all need to be of the same length, obviously, and you can also skip them\r
+// entirely and just use numbers.\r
+\r
+// Fillers to make layering more clear\r
+\r
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { \r
+ /* Layer 0: Default Layer\r
+ *,-----------------------------------------------------------------------.\r
+ * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9| F10| F11| F12|Prnt|Ins|Del| \r
+ * |----------------------------------------------------------------------|\r
+ * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| Bakspace | Home|\r
+ * |----------------------------------------------------------------------|\r
+ * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| PgUp|\r
+ * |----------------------------------------------------------------------|\r
+ * |Ctrl| A| S| D| F| G| H| J| K| L| ;| '|Enter | PgDown|\r
+ * |----------------------------------------------------------------------|\r
+ * |Shif| | Z| X| C| V| B| N| M| ,| .| /|Shift | Up| End|\r
+ * |----------------------------------------------------------------------|\r
+ * |CapsLo|Gui |Alt |Sp |Mod | Sp| Alt| Gui| Ctrl| | Lef| Dow| Rig|\r
+ * `----------------------------------------------------------------------'\r
+ */\r
+ KEYMAP(\r
+ KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_INS, KC_DEL, \r
+ KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_BSPC, KC_HOME, \r
+ KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGUP, \r
+ KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_TRNS, KC_ENT, KC_PGDN, \r
+ KC_LSFT, KC_TRNS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END, \r
+ KC_CAPS, KC_LGUI, KC_LALT, KC_SPC, MO(1), KC_SPC, KC_RALT, KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),\r
+\r
+ KEYMAP(\r
+ RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET, \r
+ RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \r
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \r
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_VOLU, \r
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY, KC_VOLD, \r
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_STOP, KC_MNXT),\r
+\r
};
\ No newline at end of file
--- /dev/null
+/*\r
+Copyright 2012 Jun Wako <wakojun@gmail.com>\r
+\r
+This program is free software: you can redistribute it and/or modify\r
+it under the terms of the GNU General Public License as published by\r
+the Free Software Foundation, either version 2 of the License, or\r
+(at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License\r
+along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+*/\r
+\r
+/*\r
+ * scan matrix\r
+ */\r
+#include <stdint.h>\r
+#include <stdbool.h>\r
+#include <avr/io.h>\r
+#include <avr/wdt.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include "print.h"\r
+#include "debug.h"\r
+#include "util.h"\r
+#include "matrix.h"\r
+#include "split_util.h"\r
+#include "pro_micro.h"\r
+#include "config.h"\r
+\r
+#ifdef USE_I2C\r
+# include "i2c.h"\r
+#else // USE_SERIAL\r
+# include "serial.h"\r
+#endif\r
+\r
+#ifndef DEBOUNCE\r
+# define DEBOUNCE 5\r
+#endif\r
+\r
+#define ERROR_DISCONNECT_COUNT 5\r
+\r
+static uint8_t debouncing = DEBOUNCE;\r
+static const int ROWS_PER_HAND = MATRIX_ROWS/2;\r
+static uint8_t error_count = 0;\r
+\r
+static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;\r
+static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;\r
+\r
+/* matrix state(1:on, 0:off) */\r
+static matrix_row_t matrix[MATRIX_ROWS];\r
+static matrix_row_t matrix_debouncing[MATRIX_ROWS];\r
+\r
+static matrix_row_t read_cols(void);\r
+static void init_cols(void);\r
+static void unselect_rows(void);\r
+static void select_row(uint8_t row);\r
+\r
+__attribute__ ((weak))\r
+void matrix_init_quantum(void) {\r
+ matrix_init_kb();\r
+}\r
+\r
+__attribute__ ((weak))\r
+void matrix_scan_quantum(void) {\r
+ matrix_scan_kb();\r
+}\r
+\r
+__attribute__ ((weak))\r
+void matrix_init_kb(void) {\r
+ matrix_init_user();\r
+}\r
+\r
+__attribute__ ((weak))\r
+void matrix_scan_kb(void) {\r
+ matrix_scan_user();\r
+}\r
+\r
+__attribute__ ((weak))\r
+void matrix_init_user(void) {\r
+}\r
+\r
+__attribute__ ((weak))\r
+void matrix_scan_user(void) {\r
+}\r
+\r
+inline\r
+uint8_t matrix_rows(void)\r
+{\r
+ return MATRIX_ROWS;\r
+}\r
+\r
+inline\r
+uint8_t matrix_cols(void)\r
+{\r
+ return MATRIX_COLS;\r
+}\r
+\r
+void matrix_init(void)\r
+{\r
+ debug_enable = true;\r
+ debug_matrix = true;\r
+ debug_mouse = true;\r
+ // initialize row and col\r
+ unselect_rows();\r
+ init_cols();\r
+\r
+ TX_RX_LED_INIT;\r
+\r
+ // initialize matrix state: all keys off\r
+ for (uint8_t i=0; i < MATRIX_ROWS; i++) {\r
+ matrix[i] = 0;\r
+ matrix_debouncing[i] = 0;\r
+ }\r
+\r
+ matrix_init_quantum();\r
+}\r
+\r
+uint8_t _matrix_scan(void)\r
+{\r
+ // Right hand is stored after the left in the matirx so, we need to offset it\r
+ int offset = isLeftHand ? 0 : (ROWS_PER_HAND);\r
+\r
+ for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {\r
+ select_row(i);\r
+ _delay_us(30); // without this wait read unstable value.\r
+ matrix_row_t cols = read_cols();\r
+ if (matrix_debouncing[i+offset] != cols) {\r
+ matrix_debouncing[i+offset] = cols;\r
+ debouncing = DEBOUNCE;\r
+ }\r
+ unselect_rows();\r
+ }\r
+\r
+ if (debouncing) {\r
+ if (--debouncing) {\r
+ _delay_ms(1);\r
+ } else {\r
+ for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {\r
+ matrix[i+offset] = matrix_debouncing[i+offset];\r
+ }\r
+ }\r
+ }\r
+\r
+ return 1;\r
+}\r
+\r
+#ifdef USE_I2C\r
+\r
+// Get rows from other half over i2c\r
+int i2c_transaction(void) {\r
+ int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;\r
+\r
+ int err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE);\r
+ if (err) goto i2c_error;\r
+\r
+ // start of matrix stored at 0x00\r
+ err = i2c_master_write(0x00);\r
+ if (err) goto i2c_error;\r
+\r
+ // Start read\r
+ err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ);\r
+ if (err) goto i2c_error;\r
+\r
+ if (!err) {\r
+ int i;\r
+ for (i = 0; i < ROWS_PER_HAND-1; ++i) {\r
+ matrix[slaveOffset+i] = i2c_master_read(I2C_ACK);\r
+ }\r
+ matrix[slaveOffset+i] = i2c_master_read(I2C_NACK);\r
+ i2c_master_stop();\r
+ } else {\r
+i2c_error: // the cable is disconnceted, or something else went wrong\r
+ i2c_reset_state();\r
+ return err;\r
+ }\r
+\r
+ return 0;\r
+}\r
+\r
+#else // USE_SERIAL\r
+\r
+int serial_transaction(void) {\r
+ int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;\r
+\r
+ if (serial_update_buffers()) {\r
+ return 1;\r
+ }\r
+\r
+ for (int i = 0; i < ROWS_PER_HAND; ++i) {\r
+ matrix[slaveOffset+i] = serial_slave_buffer[i];\r
+ }\r
+ return 0;\r
+}\r
+#endif\r
+\r
+uint8_t matrix_scan(void)\r
+{\r
+ int ret = _matrix_scan();\r
+\r
+\r
+\r
+#ifdef USE_I2C\r
+ if( i2c_transaction() ) {\r
+#else // USE_SERIAL\r
+ if( serial_transaction() ) {\r
+#endif\r
+ // turn on the indicator led when halves are disconnected\r
+ TXLED1;\r
+\r
+ error_count++;\r
+\r
+ if (error_count > ERROR_DISCONNECT_COUNT) {\r
+ // reset other half if disconnected\r
+ int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;\r
+ for (int i = 0; i < ROWS_PER_HAND; ++i) {\r
+ matrix[slaveOffset+i] = 0;\r
+ }\r
+ }\r
+ } else {\r
+ // turn off the indicator led on no error\r
+ TXLED0;\r
+ error_count = 0;\r
+ }\r
+\r
+ matrix_scan_quantum();\r
+\r
+ return ret;\r
+}\r
+\r
+void matrix_slave_scan(void) {\r
+ _matrix_scan();\r
+\r
+ int offset = (isLeftHand) ? 0 : (MATRIX_ROWS / 2);\r
+\r
+#ifdef USE_I2C\r
+ for (int i = 0; i < ROWS_PER_HAND; ++i) {\r
+ /* i2c_slave_buffer[i] = matrix[offset+i]; */\r
+ i2c_slave_buffer[i] = matrix[offset+i];\r
+ }\r
+#else // USE_SERIAL\r
+ for (int i = 0; i < ROWS_PER_HAND; ++i) {\r
+ serial_slave_buffer[i] = matrix[offset+i];\r
+ }\r
+#endif\r
+}\r
+\r
+bool matrix_is_modified(void)\r
+{\r
+ if (debouncing) return false;\r
+ return true;\r
+}\r
+\r
+inline\r
+bool matrix_is_on(uint8_t row, uint8_t col)\r
+{\r
+ return (matrix[row] & ((matrix_row_t)1<<col));\r
+}\r
+\r
+inline\r
+matrix_row_t matrix_get_row(uint8_t row)\r
+{\r
+ return matrix[row];\r
+}\r
+\r
+void matrix_print(void)\r
+{\r
+ print("\nr/c 0123456789ABCDEF\n");\r
+ for (uint8_t row = 0; row < MATRIX_ROWS; row++) {\r
+ phex(row); print(": ");\r
+ pbin_reverse16(matrix_get_row(row));\r
+ print("\n");\r
+ }\r
+}\r
+\r
+uint8_t matrix_key_count(void)\r
+{\r
+ uint8_t count = 0;\r
+ for (uint8_t i = 0; i < MATRIX_ROWS; i++) {\r
+ count += bitpop16(matrix[i]);\r
+ }\r
+ return count;\r
+}\r
+\r
+static void init_cols(void)\r
+{\r
+ for(int x = 0; x < MATRIX_COLS; x++) {\r
+ _SFR_IO8((col_pins[x] >> 4) + 1) &= ~_BV(col_pins[x] & 0xF);\r
+ _SFR_IO8((col_pins[x] >> 4) + 2) |= _BV(col_pins[x] & 0xF);\r
+ }\r
+}\r
+\r
+static matrix_row_t read_cols(void)\r
+{\r
+ matrix_row_t result = 0;\r
+ for(int x = 0; x < MATRIX_COLS; x++) {\r
+ result |= (_SFR_IO8(col_pins[x] >> 4) & _BV(col_pins[x] & 0xF)) ? 0 : (1 << x);\r
+ }\r
+ return result;\r
+}\r
+\r
+static void unselect_rows(void)\r
+{\r
+ for(int x = 0; x < ROWS_PER_HAND; x++) {\r
+ _SFR_IO8((row_pins[x] >> 4) + 1) &= ~_BV(row_pins[x] & 0xF);\r
+ _SFR_IO8((row_pins[x] >> 4) + 2) |= _BV(row_pins[x] & 0xF);\r
+ }\r
+}\r
+\r
+static void select_row(uint8_t row)\r
+{\r
+ _SFR_IO8((row_pins[row] >> 4) + 1) |= _BV(row_pins[row] & 0xF);\r
+ _SFR_IO8((row_pins[row] >> 4) + 2) &= ~_BV(row_pins[row] & 0xF);\r
+}\r
--- /dev/null
+/*\r
+ pins_arduino.h - Pin definition functions for Arduino\r
+ Part of Arduino - http://www.arduino.cc/\r
+\r
+ Copyright (c) 2007 David A. Mellis\r
+\r
+ This library is free software; you can redistribute it and/or\r
+ modify it under the terms of the GNU Lesser General Public\r
+ License as published by the Free Software Foundation; either\r
+ version 2.1 of the License, or (at your option) any later version.\r
+\r
+ This library is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+ Lesser General Public License for more details.\r
+\r
+ You should have received a copy of the GNU Lesser General\r
+ Public License along with this library; if not, write to the\r
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,\r
+ Boston, MA 02111-1307 USA\r
+\r
+ $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $\r
+*/\r
+\r
+#ifndef Pins_Arduino_h\r
+#define Pins_Arduino_h\r
+\r
+#include <avr/pgmspace.h>\r
+\r
+// Workaround for wrong definitions in "iom32u4.h".\r
+// This should be fixed in the AVR toolchain.\r
+#undef UHCON\r
+#undef UHINT\r
+#undef UHIEN\r
+#undef UHADDR\r
+#undef UHFNUM\r
+#undef UHFNUML\r
+#undef UHFNUMH\r
+#undef UHFLEN\r
+#undef UPINRQX\r
+#undef UPINTX\r
+#undef UPNUM\r
+#undef UPRST\r
+#undef UPCONX\r
+#undef UPCFG0X\r
+#undef UPCFG1X\r
+#undef UPSTAX\r
+#undef UPCFG2X\r
+#undef UPIENX\r
+#undef UPDATX\r
+#undef TCCR2A\r
+#undef WGM20\r
+#undef WGM21\r
+#undef COM2B0\r
+#undef COM2B1\r
+#undef COM2A0\r
+#undef COM2A1\r
+#undef TCCR2B\r
+#undef CS20\r
+#undef CS21\r
+#undef CS22\r
+#undef WGM22\r
+#undef FOC2B\r
+#undef FOC2A\r
+#undef TCNT2\r
+#undef TCNT2_0\r
+#undef TCNT2_1\r
+#undef TCNT2_2\r
+#undef TCNT2_3\r
+#undef TCNT2_4\r
+#undef TCNT2_5\r
+#undef TCNT2_6\r
+#undef TCNT2_7\r
+#undef OCR2A\r
+#undef OCR2_0\r
+#undef OCR2_1\r
+#undef OCR2_2\r
+#undef OCR2_3\r
+#undef OCR2_4\r
+#undef OCR2_5\r
+#undef OCR2_6\r
+#undef OCR2_7\r
+#undef OCR2B\r
+#undef OCR2_0\r
+#undef OCR2_1\r
+#undef OCR2_2\r
+#undef OCR2_3\r
+#undef OCR2_4\r
+#undef OCR2_5\r
+#undef OCR2_6\r
+#undef OCR2_7\r
+\r
+#define NUM_DIGITAL_PINS 30\r
+#define NUM_ANALOG_INPUTS 12\r
+\r
+#define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0)\r
+#define TXLED0 PORTD |= (1<<5)\r
+#define TXLED1 PORTD &= ~(1<<5)\r
+#define RXLED0 PORTB |= (1<<0)\r
+#define RXLED1 PORTB &= ~(1<<0)\r
+\r
+static const uint8_t SDA = 2;\r
+static const uint8_t SCL = 3;\r
+#define LED_BUILTIN 13\r
+\r
+// Map SPI port to 'new' pins D14..D17\r
+static const uint8_t SS = 17;\r
+static const uint8_t MOSI = 16;\r
+static const uint8_t MISO = 14;\r
+static const uint8_t SCK = 15;\r
+\r
+// Mapping of analog pins as digital I/O\r
+// A6-A11 share with digital pins\r
+static const uint8_t ADC0 = 18;\r
+static const uint8_t ADC1 = 19;\r
+static const uint8_t ADC2 = 20;\r
+static const uint8_t ADC3 = 21;\r
+static const uint8_t ADC4 = 22;\r
+static const uint8_t ADC5 = 23;\r
+static const uint8_t ADC6 = 24; // D4\r
+static const uint8_t ADC7 = 25; // D6\r
+static const uint8_t ADC8 = 26; // D8\r
+static const uint8_t ADC9 = 27; // D9\r
+static const uint8_t ADC10 = 28; // D10\r
+static const uint8_t ADC11 = 29; // D12\r
+\r
+#define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0))\r
+#define digitalPinToPCICRbit(p) 0\r
+#define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0))\r
+#define digitalPinToPCMSKbit(p) ( ((p) >= 8 && (p) <= 11) ? (p) - 4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4))))))\r
+\r
+// __AVR_ATmega32U4__ has an unusual mapping of pins to channels\r
+extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];\r
+#define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) )\r
+\r
+#define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT)))))\r
+\r
+#ifdef ARDUINO_MAIN\r
+\r
+// On the Arduino board, digital pins are also used\r
+// for the analog output (software PWM). Analog input\r
+// pins are a separate set.\r
+\r
+// ATMEL ATMEGA32U4 / ARDUINO LEONARDO\r
+//\r
+// D0 PD2 RXD1/INT2\r
+// D1 PD3 TXD1/INT3\r
+// D2 PD1 SDA SDA/INT1\r
+// D3# PD0 PWM8/SCL OC0B/SCL/INT0\r
+// D4 A6 PD4 ADC8\r
+// D5# PC6 ??? OC3A/#OC4A\r
+// D6# A7 PD7 FastPWM #OC4D/ADC10\r
+// D7 PE6 INT6/AIN0\r
+//\r
+// D8 A8 PB4 ADC11/PCINT4\r
+// D9# A9 PB5 PWM16 OC1A/#OC4B/ADC12/PCINT5\r
+// D10# A10 PB6 PWM16 OC1B/0c4B/ADC13/PCINT6\r
+// D11# PB7 PWM8/16 0C0A/OC1C/#RTS/PCINT7\r
+// D12 A11 PD6 T1/#OC4D/ADC9\r
+// D13# PC7 PWM10 CLK0/OC4A\r
+//\r
+// A0 D18 PF7 ADC7\r
+// A1 D19 PF6 ADC6\r
+// A2 D20 PF5 ADC5\r
+// A3 D21 PF4 ADC4\r
+// A4 D22 PF1 ADC1\r
+// A5 D23 PF0 ADC0\r
+//\r
+// New pins D14..D17 to map SPI port to digital pins\r
+//\r
+// MISO D14 PB3 MISO,PCINT3\r
+// SCK D15 PB1 SCK,PCINT1\r
+// MOSI D16 PB2 MOSI,PCINT2\r
+// SS D17 PB0 RXLED,SS/PCINT0\r
+//\r
+// Connected LEDs on board for TX and RX\r
+// TXLED D24 PD5 XCK1\r
+// RXLED D17 PB0\r
+// HWB PE2 HWB\r
+\r
+// these arrays map port names (e.g. port B) to the\r
+// appropriate addresses for various functions (e.g. reading\r
+// and writing)\r
+const uint16_t PROGMEM port_to_mode_PGM[] = {\r
+ NOT_A_PORT,\r
+ NOT_A_PORT,\r
+ (uint16_t) &DDRB,\r
+ (uint16_t) &DDRC,\r
+ (uint16_t) &DDRD,\r
+ (uint16_t) &DDRE,\r
+ (uint16_t) &DDRF,\r
+};\r
+\r
+const uint16_t PROGMEM port_to_output_PGM[] = {\r
+ NOT_A_PORT,\r
+ NOT_A_PORT,\r
+ (uint16_t) &PORTB,\r
+ (uint16_t) &PORTC,\r
+ (uint16_t) &PORTD,\r
+ (uint16_t) &PORTE,\r
+ (uint16_t) &PORTF,\r
+};\r
+\r
+const uint16_t PROGMEM port_to_input_PGM[] = {\r
+ NOT_A_PORT,\r
+ NOT_A_PORT,\r
+ (uint16_t) &PINB,\r
+ (uint16_t) &PINC,\r
+ (uint16_t) &PIND,\r
+ (uint16_t) &PINE,\r
+ (uint16_t) &PINF,\r
+};\r
+\r
+const uint8_t PROGMEM digital_pin_to_port_PGM[] = {\r
+ PD, // D0 - PD2\r
+ PD, // D1 - PD3\r
+ PD, // D2 - PD1\r
+ PD, // D3 - PD0\r
+ PD, // D4 - PD4\r
+ PC, // D5 - PC6\r
+ PD, // D6 - PD7\r
+ PE, // D7 - PE6\r
+\r
+ PB, // D8 - PB4\r
+ PB, // D9 - PB5\r
+ PB, // D10 - PB6\r
+ PB, // D11 - PB7\r
+ PD, // D12 - PD6\r
+ PC, // D13 - PC7\r
+\r
+ PB, // D14 - MISO - PB3\r
+ PB, // D15 - SCK - PB1\r
+ PB, // D16 - MOSI - PB2\r
+ PB, // D17 - SS - PB0\r
+\r
+ PF, // D18 - A0 - PF7\r
+ PF, // D19 - A1 - PF6\r
+ PF, // D20 - A2 - PF5\r
+ PF, // D21 - A3 - PF4\r
+ PF, // D22 - A4 - PF1\r
+ PF, // D23 - A5 - PF0\r
+\r
+ PD, // D24 - PD5\r
+ PD, // D25 / D6 - A7 - PD7\r
+ PB, // D26 / D8 - A8 - PB4\r
+ PB, // D27 / D9 - A9 - PB5\r
+ PB, // D28 / D10 - A10 - PB6\r
+ PD, // D29 / D12 - A11 - PD6\r
+};\r
+\r
+const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {\r
+ _BV(2), // D0 - PD2\r
+ _BV(3), // D1 - PD3\r
+ _BV(1), // D2 - PD1\r
+ _BV(0), // D3 - PD0\r
+ _BV(4), // D4 - PD4\r
+ _BV(6), // D5 - PC6\r
+ _BV(7), // D6 - PD7\r
+ _BV(6), // D7 - PE6\r
+\r
+ _BV(4), // D8 - PB4\r
+ _BV(5), // D9 - PB5\r
+ _BV(6), // D10 - PB6\r
+ _BV(7), // D11 - PB7\r
+ _BV(6), // D12 - PD6\r
+ _BV(7), // D13 - PC7\r
+\r
+ _BV(3), // D14 - MISO - PB3\r
+ _BV(1), // D15 - SCK - PB1\r
+ _BV(2), // D16 - MOSI - PB2\r
+ _BV(0), // D17 - SS - PB0\r
+\r
+ _BV(7), // D18 - A0 - PF7\r
+ _BV(6), // D19 - A1 - PF6\r
+ _BV(5), // D20 - A2 - PF5\r
+ _BV(4), // D21 - A3 - PF4\r
+ _BV(1), // D22 - A4 - PF1\r
+ _BV(0), // D23 - A5 - PF0\r
+\r
+ _BV(5), // D24 - PD5\r
+ _BV(7), // D25 / D6 - A7 - PD7\r
+ _BV(4), // D26 / D8 - A8 - PB4\r
+ _BV(5), // D27 / D9 - A9 - PB5\r
+ _BV(6), // D28 / D10 - A10 - PB6\r
+ _BV(6), // D29 / D12 - A11 - PD6\r
+};\r
+\r
+const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ TIMER0B, /* 3 */\r
+ NOT_ON_TIMER,\r
+ TIMER3A, /* 5 */\r
+ TIMER4D, /* 6 */\r
+ NOT_ON_TIMER,\r
+\r
+ NOT_ON_TIMER,\r
+ TIMER1A, /* 9 */\r
+ TIMER1B, /* 10 */\r
+ TIMER0A, /* 11 */\r
+\r
+ NOT_ON_TIMER,\r
+ TIMER4A, /* 13 */\r
+\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+ NOT_ON_TIMER,\r
+};\r
+\r
+const uint8_t PROGMEM analog_pin_to_channel_PGM[] = {\r
+ 7, // A0 PF7 ADC7\r
+ 6, // A1 PF6 ADC6\r
+ 5, // A2 PF5 ADC5\r
+ 4, // A3 PF4 ADC4\r
+ 1, // A4 PF1 ADC1\r
+ 0, // A5 PF0 ADC0\r
+ 8, // A6 D4 PD4 ADC8\r
+ 10, // A7 D6 PD7 ADC10\r
+ 11, // A8 D8 PB4 ADC11\r
+ 12, // A9 D9 PB5 ADC12\r
+ 13, // A10 D10 PB6 ADC13\r
+ 9 // A11 D12 PD6 ADC9\r
+};\r
+\r
+#endif /* ARDUINO_MAIN */\r
+\r
+// These serial port names are intended to allow libraries and architecture-neutral\r
+// sketches to automatically default to the correct port name for a particular type\r
+// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,\r
+// the first hardware serial port whose RX/TX pins are not dedicated to another use.\r
+//\r
+// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor\r
+//\r
+// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial\r
+//\r
+// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library\r
+//\r
+// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.\r
+//\r
+// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX\r
+// pins are NOT connected to anything by default.\r
+#define SERIAL_PORT_MONITOR Serial\r
+#define SERIAL_PORT_USBVIRTUAL Serial\r
+#define SERIAL_PORT_HARDWARE Serial1\r
+#define SERIAL_PORT_HARDWARE_OPEN Serial1\r
+\r
+#endif /* Pins_Arduino_h */\r
--- /dev/null
+DeltaSplit75\r
+======\r
+\r
+This readme and most of the code are from https://github.com/ahtn/tmk_keyboard/ and https://github.com/qmk/qmk_firmware/tree/master/keyboards/lets_split\r
+\r
+Credit to ahtn and wootpatoot for work on the split keyboard firmware\r
+\r
+Split keyboard firmware for Arduino Pro Micro or other ATmega32u4\r
+based boards.\r
+\r
+## Case Files\r
+Files are available here: https://github.com/xyxjj/DeltaSplit75-Case-files\r
+\r
+\r
+## First Time Setup\r
+\r
+Download or clone the whole firmware and navigate to the keyboards/DeltaSplit75 directory. Once your dev env is setup, you'll be able to generate the default .hex using:\r
+\r
+```\r
+make V2\r
+\r
+or\r
+\r
+make ProtoSplit-ProtoSplit (if you have one of the prototype PCBs)\r
+```\r
+\r
+You will see a lot of output and if everything worked correctly you will see the built hex files:\r
+\r
+```\r
+DeltaSplit75_ProtoSplit_ProtoSplit.hex\r
+\r
+or\r
+\r
+DeltaSplit75_V2_Default.hex\r
+\r
+```\r
+\r
+\r
+For more information on customizing keymaps, take a look at the primary documentation for [Customizing Your Keymap](/readme.md##customizing-your-keymap) in the main readme.md.\r
+\r
+### DeltaSplit75 V2\r
+The PCBs available in groupbuy are all v2, if you've bought one of my prototype PCBs (it says DeltaSplit65 on the silkscreen instead of 75), use the code make ProtoSplit-ProtoSplit instead\r
+\r
+Features\r
+--------\r
+\r
+For the full Quantum Mechanical Keyboard feature list, see [the parent readme.md](/readme.md).\r
+\r
+Some features supported by the firmware:\r
+\r
+* Either half can connect to the computer via USB, or both halves can be used\r
+ independently.\r
+* 75% formfactor\r
+* Support for multiple Bottom Rows\r
+* RGB underglow support\r
+* Split Backspace and ISO support\r
+\r
+\r
+Flashing\r
+-------\r
+I personally use xLoader to upload my hex files to the keyboard, though any other working software is fine too\r
+\r
+\r
+Choosing which board to plug the USB cable into (choosing Master)\r
+--------\r
+Because the two boards are identical, the firmware has logic to differentiate the left and right board.\r
+\r
+It uses two strategies to figure things out: look at the EEPROM (memory on the chip) or looks if the current board has the usb cable.\r
+\r
+The EEPROM approach requires additional setup (flashing the eeeprom) but allows you to swap the usb cable to either side.\r
+\r
+The USB cable approach is easier to setup and if you just want the usb cable on the left board, you do not need to do anything extra.\r
+\r
+### Setting the left hand as master\r
+If you always plug the usb cable into the left board, nothing extra is needed as this is the default. Comment out `EE_HANDS` and comment out `I2C_MASTER_RIGHT` or `MASTER_RIGHT` if for some reason it was set.\r
+\r
+### Setting the right hand as master\r
+If you always plug the usb cable into the right board, add an extra flag to your `config.h`\r
+```\r
+ #define MASTER_RIGHT\r
+```\r
+\r
+### Setting EE_hands to use either hands as master\r
+If you define `EE_HANDS` in your `config.h`, you will need to set the\r
+EEPROM for the left and right halves.\r
+\r
+The EEPROM is used to store whether the\r
+half is left handed or right handed. This makes it so that the same firmware\r
+file will run on both hands instead of having to flash left and right handed\r
+versions of the firmware to each half. To flash the EEPROM file for the left\r
+half run:\r
+```\r
+avrdude -p atmega32u4 -P $(COM_PORT) -c avr109 -U eeprom:w:eeprom-lefthand.eep\r
+// or the equivalent in dfu-programmer\r
+\r
+```\r
+and similarly for right half\r
+```\r
+avrdude -p atmega32u4 -P $(COM_PORT) -c avr109 -U eeprom:w:eeprom-righhand.eep\r
+// or the equivalent in dfu-programmer\r
+```\r
+\r
+NOTE: replace `$(COM_PORT)` with the port of your device (e.g. `/dev/ttyACM0`)\r
+\r
+After you have flashed the EEPROM, you then need to set `EE_HANDS` in your config.h, rebuild the hex files and reflash.\r
+\r
+Note that you need to program both halves, but you have the option of using\r
+different keymaps for each half. You could program the left half with a QWERTY\r
+layout and the right half with a Colemak layout using bootmagic's default layout option.\r
+Then if you connect the left half to a computer by USB the keyboard will use QWERTY and Colemak when the\r
+right half is connected.\r
+\r
+\r
+Notes on Using Pro Micro 3.3V\r
+-----------------------------\r
+\r
+Do update the `F_CPU` parameter in `rules.mk` to `8000000` which reflects\r
+the frequency on the 3.3V board.\r
+\r
+Also, if the slave board is producing weird characters in certain columns,\r
+update the following line in `matrix.c` to the following:\r
+\r
+```\r
+// _delay_us(30); // without this wait read unstable value.\r
+_delay_us(300); // without this wait read unstable value.\r
+```\r
--- /dev/null
+SRC += matrix.c \
+ i2c.c \
+ split_util.c \
+ serial.c
+
+# MCU name
+#MCU = at90usb1287
+MCU = atmega32u4
+
+# Processor frequency.
+# This will define a symbol, F_CPU, in all source code files equal to the
+# processor frequency in Hz. You can then use this symbol in your source code to
+# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+# automatically to create a 32-bit value in your source code.
+#
+# This will be an integer division of F_USB below, as it is sourced by
+# F_USB after it has run through any CPU prescalers. Note that this value
+# does not *change* the processor frequency - it should merely be updated to
+# reflect the processor speed set externally so that the code can use accurate
+# software delays.
+F_CPU = 16000000
+
+#
+# LUFA specific
+#
+# Target architecture (see library "Board Types" documentation).
+ARCH = AVR8
+
+# Input clock frequency.
+# This will define a symbol, F_USB, in all source code files equal to the
+# input clock frequency (before any prescaling is performed) in Hz. This value may
+# differ from F_CPU if prescaling is used on the latter, and is required as the
+# raw input clock is fed directly to the PLL sections of the AVR for high speed
+# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+# at the end, this will be done automatically to create a 32-bit value in your
+# source code.
+#
+# If no clock division is performed on the input clock inside the AVR (via the
+# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_USB = $(F_CPU)
+
+# Interrupt driven control endpoint task(+60)
+OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
+
+
+# Boot Section Size in *bytes*
+# Teensy halfKay 512
+# Teensy++ halfKay 1024
+# Atmel DFU loader 4096
+# LUFA bootloader 4096
+# USBaspLoader 2048
+OPT_DEFS += -DBOOTLOADER_SIZE=4096
+
+# Build Options
+# change to "no" to disable the options, or define them in the Makefile in
+# the appropriate keymap folder that will get included automatically
+#
+BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700)
+EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450)
+CONSOLE_ENABLE ?= no # Console for debug(+400)
+COMMAND_ENABLE ?= yes # Commands for debug and configuration
+NKRO_ENABLE ?= no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality
+MIDI_ENABLE ?= no # MIDI controls
+AUDIO_ENABLE ?= no # Audio output on port C6
+UNICODE_ENABLE ?= no # Unicode
+BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID
+RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time.
+SUBPROJECT_rev1 ?= yes
+USE_I2C ?= yes
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
+SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend
+
+CUSTOM_MATRIX = yes
+
+avrdude: build
+ ls /dev/tty* > /tmp/1; \
+ echo "Reset your Pro Micro now"; \
+ while [[ -z $$USB ]]; do \
+ sleep 1; \
+ ls /dev/tty* > /tmp/2; \
+ USB=`diff /tmp/1 /tmp/2 | grep -o '/dev/tty.*'`; \
+ done; \
+ avrdude -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex
+
+.PHONY: avrdude
--- /dev/null
+/*\r
+ * WARNING: be careful changing this code, it is very timing dependent\r
+ */\r
+\r
+#ifndef F_CPU\r
+#define F_CPU 16000000\r
+#endif\r
+\r
+#include <avr/io.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <stdbool.h>\r
+#include "serial.h"\r
+\r
+#ifdef USE_SERIAL\r
+\r
+// Serial pulse period in microseconds. Its probably a bad idea to lower this\r
+// value.\r
+#define SERIAL_DELAY 24\r
+\r
+uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};\r
+uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};\r
+\r
+#define SLAVE_DATA_CORRUPT (1<<0)\r
+volatile uint8_t status = 0;\r
+\r
+inline static\r
+void serial_delay(void) {\r
+ _delay_us(SERIAL_DELAY);\r
+}\r
+\r
+inline static\r
+void serial_output(void) {\r
+ SERIAL_PIN_DDR |= SERIAL_PIN_MASK;\r
+}\r
+\r
+// make the serial pin an input with pull-up resistor\r
+inline static\r
+void serial_input(void) {\r
+ SERIAL_PIN_DDR &= ~SERIAL_PIN_MASK;\r
+ SERIAL_PIN_PORT |= SERIAL_PIN_MASK;\r
+}\r
+\r
+inline static\r
+uint8_t serial_read_pin(void) {\r
+ return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK);\r
+}\r
+\r
+inline static\r
+void serial_low(void) {\r
+ SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK;\r
+}\r
+\r
+inline static\r
+void serial_high(void) {\r
+ SERIAL_PIN_PORT |= SERIAL_PIN_MASK;\r
+}\r
+\r
+void serial_master_init(void) {\r
+ serial_output();\r
+ serial_high();\r
+}\r
+\r
+void serial_slave_init(void) {\r
+ serial_input();\r
+\r
+ // Enable INT0\r
+ EIMSK |= _BV(INT0);\r
+ // Trigger on falling edge of INT0\r
+ EICRA &= ~(_BV(ISC00) | _BV(ISC01));\r
+}\r
+\r
+// Used by the master to synchronize timing with the slave.\r
+static\r
+void sync_recv(void) {\r
+ serial_input();\r
+ // This shouldn't hang if the slave disconnects because the\r
+ // serial line will float to high if the slave does disconnect.\r
+ while (!serial_read_pin());\r
+ serial_delay();\r
+}\r
+\r
+// Used by the slave to send a synchronization signal to the master.\r
+static\r
+void sync_send(void) {\r
+ serial_output();\r
+\r
+ serial_low();\r
+ serial_delay();\r
+\r
+ serial_high();\r
+}\r
+\r
+// Reads a byte from the serial line\r
+static\r
+uint8_t serial_read_byte(void) {\r
+ uint8_t byte = 0;\r
+ serial_input();\r
+ for ( uint8_t i = 0; i < 8; ++i) {\r
+ byte = (byte << 1) | serial_read_pin();\r
+ serial_delay();\r
+ _delay_us(1);\r
+ }\r
+\r
+ return byte;\r
+}\r
+\r
+// Sends a byte with MSB ordering\r
+static\r
+void serial_write_byte(uint8_t data) {\r
+ uint8_t b = 8;\r
+ serial_output();\r
+ while( b-- ) {\r
+ if(data & (1 << b)) {\r
+ serial_high();\r
+ } else {\r
+ serial_low();\r
+ }\r
+ serial_delay();\r
+ }\r
+}\r
+\r
+// interrupt handle to be used by the slave device\r
+ISR(SERIAL_PIN_INTERRUPT) {\r
+ sync_send();\r
+\r
+ uint8_t checksum = 0;\r
+ for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) {\r
+ serial_write_byte(serial_slave_buffer[i]);\r
+ sync_send();\r
+ checksum += serial_slave_buffer[i];\r
+ }\r
+ serial_write_byte(checksum);\r
+ sync_send();\r
+\r
+ // wait for the sync to finish sending\r
+ serial_delay();\r
+\r
+ // read the middle of pulses\r
+ _delay_us(SERIAL_DELAY/2);\r
+\r
+ uint8_t checksum_computed = 0;\r
+ for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) {\r
+ serial_master_buffer[i] = serial_read_byte();\r
+ sync_send();\r
+ checksum_computed += serial_master_buffer[i];\r
+ }\r
+ uint8_t checksum_received = serial_read_byte();\r
+ sync_send();\r
+\r
+ serial_input(); // end transaction\r
+\r
+ if ( checksum_computed != checksum_received ) {\r
+ status |= SLAVE_DATA_CORRUPT;\r
+ } else {\r
+ status &= ~SLAVE_DATA_CORRUPT;\r
+ }\r
+}\r
+\r
+inline\r
+bool serial_slave_DATA_CORRUPT(void) {\r
+ return status & SLAVE_DATA_CORRUPT;\r
+}\r
+\r
+// Copies the serial_slave_buffer to the master and sends the\r
+// serial_master_buffer to the slave.\r
+//\r
+// Returns:\r
+// 0 => no error\r
+// 1 => slave did not respond\r
+int serial_update_buffers(void) {\r
+ // this code is very time dependent, so we need to disable interrupts\r
+ cli();\r
+\r
+ // signal to the slave that we want to start a transaction\r
+ serial_output();\r
+ serial_low();\r
+ _delay_us(1);\r
+\r
+ // wait for the slaves response\r
+ serial_input();\r
+ serial_high();\r
+ _delay_us(SERIAL_DELAY);\r
+\r
+ // check if the slave is present\r
+ if (serial_read_pin()) {\r
+ // slave failed to pull the line low, assume not present\r
+ sei();\r
+ return 1;\r
+ }\r
+\r
+ // if the slave is present syncronize with it\r
+ sync_recv();\r
+\r
+ uint8_t checksum_computed = 0;\r
+ // receive data from the slave\r
+ for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) {\r
+ serial_slave_buffer[i] = serial_read_byte();\r
+ sync_recv();\r
+ checksum_computed += serial_slave_buffer[i];\r
+ }\r
+ uint8_t checksum_received = serial_read_byte();\r
+ sync_recv();\r
+\r
+ if (checksum_computed != checksum_received) {\r
+ sei();\r
+ return 1;\r
+ }\r
+\r
+ uint8_t checksum = 0;\r
+ // send data to the slave\r
+ for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) {\r
+ serial_write_byte(serial_master_buffer[i]);\r
+ sync_recv();\r
+ checksum += serial_master_buffer[i];\r
+ }\r
+ serial_write_byte(checksum);\r
+ sync_recv();\r
+\r
+ // always, release the line when not in use\r
+ serial_output();\r
+ serial_high();\r
+\r
+ sei();\r
+ return 0;\r
+}\r
+\r
+#endif\r
--- /dev/null
+#ifndef MY_SERIAL_H\r
+#define MY_SERIAL_H\r
+\r
+#include "config.h"\r
+#include <stdbool.h>\r
+\r
+/* TODO: some defines for interrupt setup */\r
+#define SERIAL_PIN_DDR DDRD\r
+#define SERIAL_PIN_PORT PORTD\r
+#define SERIAL_PIN_INPUT PIND\r
+#define SERIAL_PIN_MASK _BV(PD0)\r
+#define SERIAL_PIN_INTERRUPT INT0_vect\r
+\r
+#define SERIAL_SLAVE_BUFFER_LENGTH ((MATRIX_COLS+7)/8 *MATRIX_ROWS/2)\r
+#define SERIAL_MASTER_BUFFER_LENGTH 1\r
+\r
+// Buffers for master - slave communication\r
+extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];\r
+extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];\r
+\r
+void serial_master_init(void);\r
+void serial_slave_init(void);\r
+int serial_update_buffers(void);\r
+bool serial_slave_data_corrupt(void);\r
+\r
+#endif\r
--- /dev/null
+#include <avr/io.h>\r
+#include <avr/wdt.h>\r
+#include <avr/power.h>\r
+#include <avr/interrupt.h>\r
+#include <util/delay.h>\r
+#include <avr/eeprom.h>\r
+#include "split_util.h"\r
+#include "matrix.h"\r
+#include "keyboard.h"\r
+#include "config.h"\r
+\r
+#ifdef USE_I2C\r
+# include "i2c.h"\r
+#else\r
+# include "serial.h"\r
+#endif\r
+\r
+volatile bool isLeftHand = true;\r
+\r
+static void setup_handedness(void) {\r
+ #ifdef EE_HANDS\r
+ isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS);\r
+ #else\r
+ // I2C_MASTER_RIGHT is deprecated use MASTER_RIGHT instead since this works for both serial and i2c\r
+ #if defined(I2C_MASTER_RIGHT) || defined(MASTER_RIGHT)\r
+ isLeftHand = !has_usb();\r
+ #else\r
+ isLeftHand = has_usb();\r
+ #endif\r
+ #endif\r
+}\r
+\r
+static void keyboard_master_setup(void) {\r
+#ifdef USE_I2C\r
+ i2c_master_init();\r
+#else\r
+ serial_master_init();\r
+#endif\r
+}\r
+\r
+static void keyboard_slave_setup(void) {\r
+#ifdef USE_I2C\r
+ i2c_slave_init(SLAVE_I2C_ADDRESS);\r
+#else\r
+ serial_slave_init();\r
+#endif\r
+}\r
+\r
+bool has_usb(void) {\r
+ USBCON |= (1 << OTGPADE); //enables VBUS pad\r
+ _delay_us(5);\r
+ return (USBSTA & (1<<VBUS)); //checks state of VBUS\r
+}\r
+\r
+void split_keyboard_setup(void) {\r
+ setup_handedness();\r
+\r
+ if (has_usb()) {\r
+ keyboard_master_setup();\r
+ } else {\r
+ keyboard_slave_setup();\r
+ }\r
+ sei();\r
+}\r
+\r
+void keyboard_slave_loop(void) {\r
+ matrix_init();\r
+\r
+ while (1) {\r
+ matrix_slave_scan();\r
+ }\r
+}\r
+\r
+// this code runs before the usb and keyboard is initialized\r
+void matrix_setup(void) {\r
+ split_keyboard_setup();\r
+\r
+ if (!has_usb()) {\r
+ keyboard_slave_loop();\r
+ }\r
+}\r
--- /dev/null
+#ifndef SPLIT_KEYBOARD_UTIL_H\r
+#define SPLIT_KEYBOARD_UTIL_H\r
+\r
+#include <stdbool.h>\r
+\r
+#ifdef EE_HANDS\r
+ #define EECONFIG_BOOTMAGIC_END (uint8_t *)10\r
+ #define EECONFIG_HANDEDNESS EECONFIG_BOOTMAGIC_END\r
+#endif\r
+\r
+#define SLAVE_I2C_ADDRESS 0x32\r
+\r
+extern volatile bool isLeftHand;\r
+\r
+// slave version of matix scan, defined in matrix.c\r
+void matrix_slave_scan(void);\r
+\r
+void split_keyboard_setup(void);\r
+bool has_usb(void);\r
+void keyboard_slave_loop(void);\r
+\r
+#endif\r
--- /dev/null
+ifndef MAKEFILE_INCLUDED
+ include ../../Makefile
+endif
\ No newline at end of file
--- /dev/null
+/*\r
+Copyright 2012 Jun Wako <wakojun@gmail.com>\r
+\r
+This program is free software: you can redistribute it and/or modify\r
+it under the terms of the GNU General Public License as published by\r
+the Free Software Foundation, either version 2 of the License, or\r
+(at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License\r
+along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+*/\r
+\r
+#ifndef CONFIG_H\r
+#define CONFIG_H\r
+\r
+#include "config_common.h"\r
+\r
+/* USB Device descriptor parameter */\r
+#define VENDOR_ID 0xFEED\r
+#define PRODUCT_ID 0x3060\r
+#define DEVICE_VER 0x0001\r
+#define MANUFACTURER xyxjj\r
+#define PRODUCT DeltaSplit75\r
+#define DESCRIPTION 75% split keyboard\r
+\r
+/* key matrix size */\r
+// Rows are doubled-up\r
+#define MATRIX_ROWS 14\r
+#define MATRIX_COLS 8\r
+\r
+// wiring of each half\r
+#define MATRIX_ROW_PINS { F4, F5, F6, F7, B1, B3, B2 }\r
+#define MATRIX_COL_PINS { B6, B5, B4, E6, D7, C6, D4, D1}\r
+\r
+#define CATERINA_BOOTLOADER\r
+\r
+/* COL2ROW or ROW2COL */\r
+#define DIODE_DIRECTION COL2ROW\r
+\r
+/* define if matrix has ghost */\r
+//#define MATRIX_HAS_GHOST\r
+\r
+/* number of backlight levels */\r
+// #define BACKLIGHT_LEVELS 3\r
+\r
+/* Set 0 if debouncing isn't needed */\r
+#define DEBOUNCING_DELAY 5\r
+\r
+/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */\r
+#define LOCKING_SUPPORT_ENABLE\r
+/* Locking resynchronize hack */\r
+#define LOCKING_RESYNC_ENABLE\r
+\r
+/* key combination for command */\r
+#define IS_COMMAND() ( \\r
+ keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \\r
+)\r
+\r
+/* ws2812 RGB LED */\r
+#define RGB_DI_PIN D3\r
+#define RGBLIGHT_TIMER\r
+#define RGBLED_NUM 12 // Number of LEDs\r
+#define ws2812_PORTREG PORTD\r
+#define ws2812_DDRREG DDRD\r
+\r
+/*\r
+ * Feature disable options\r
+ * These options are also useful to firmware size reduction.\r
+ */\r
+\r
+/* disable debug print */\r
+// #define NO_DEBUG\r
+\r
+/* disable print */\r
+// #define NO_PRINT\r
+\r
+/* disable action features */\r
+//#define NO_ACTION_LAYER\r
+//#define NO_ACTION_TAPPING\r
+//#define NO_ACTION_ONESHOT\r
+//#define NO_ACTION_MACRO\r
+//#define NO_ACTION_FUNCTION\r
+\r
+\r
+#endif
\ No newline at end of file
--- /dev/null
+BACKLIGHT_ENABLE = no
+
+ifndef QUANTUM_DIR
+ include ../../../Makefile
+endif
--- /dev/null
+#include "deltasplit75.h"\r
+\r
+#ifdef AUDIO_ENABLE\r
+ float tone_startup[][2] = SONG(STARTUP_SOUND);\r
+ float tone_goodbye[][2] = SONG(GOODBYE_SOUND);\r
+#endif\r
+\r
+void matrix_init_kb(void) {\r
+\r
+ #ifdef AUDIO_ENABLE\r
+ _delay_ms(20); // gets rid of tick\r
+ PLAY_NOTE_ARRAY(tone_startup, false, 0);\r
+ #endif\r
+\r
+ // // green led on\r
+ // DDRD |= (1<<5);\r
+ // PORTD &= ~(1<<5);\r
+\r
+ // // orange led on\r
+ // DDRB |= (1<<0);\r
+ // PORTB &= ~(1<<0);\r
+\r
+ matrix_init_user();\r
+};\r
+\r
+void shutdown_user(void) {\r
+ #ifdef AUDIO_ENABLE\r
+ PLAY_NOTE_ARRAY(tone_goodbye, false, 0);\r
+ _delay_ms(150);\r
+ stop_all_notes();\r
+ #endif\r
+}\r
--- /dev/null
+#ifndef v2_H\r
+#define v2_H\r
+\r
+#include "../deltasplit75.h"\r
+\r
+//void promicro_bootloader_jmp(bool program);\r
+#include "quantum.h"\r
+\r
+//void promicro_bootloader_jmp(bool program);\r
+//matrix is defined in a weird way here; the layout on both sides are asymmetrical, but the "matrix" is symmetrical but with empty gaps\r
+//the last column is defined as a separate row because the firmware currently doesnt support more than 8 columns (this layout has 9 columns per side) K45 and K110 are the Bs on both sides; K53 and K106 are extra keys for ISO\r
+#define KEYMAP( \\r
+ K00, K01, K02, K03, K04, K05, K06, K70, K71, K72, K73, K74, K75, K76, K77, K132, \\r
+ K10, K11, K12, K13, K14, K15, K16, K80, K81, K82, K83, K84, K85, K86, K87, K133, \\r
+ K20, K21, K22, K23, K24, K25, K90, K91, K92, K93, K94, K95, K96, K97, K134, \\r
+ K30, K31, K32, K33, K34, K35, K100, K101, K102, K103, K104, K105, K106, K107, K135, \\r
+ K40, K53, K41, K42, K43, K44, K45, K110, K111, K112, K113, K114, K115, K116, K117, K136, \\r
+ K50, K51, K52, K54, K55, K120, K121, K122, K123, K126, K127, K137 \\r
+ ) \\r
+ { \\r
+ { K00, K01, K02, K03, K04, K05, K06, KC_NO}, \\r
+ { K10, K11, K12, K13, K14, K15, K16, KC_NO}, \\r
+ { K20, K21, K22, K23, K24, K25, KC_NO, KC_NO}, \\r
+ { K30, K31, K32, K33, K34, K35, KC_NO, KC_NO}, \\r
+ { K40, K41, K42, K43, K44, K45, KC_NO, KC_NO}, \\r
+ { K50, K51, K52, K53, K54, K55, KC_NO, KC_NO}, \\r
+ { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO}, \\r
+ { K70 , K71, K72, K73, K74, K75, K76, K77}, \\r
+ { K80, K81, K82, K83, K84, K85, K86, K87}, \\r
+ { K90, K91, K92, K93, K94, K95, K96, K97}, \\r
+ { K100, K101, K102, K103, K104, K105, K106, K107}, \\r
+ { K110, K111, K112, K113, K114, K115, K116, K117}, \\r
+ { K120, K121, K122, K123, KC_NO, KC_NO, K126, K127}, \\r
+ { KC_NO, KC_NO, K132, K133, K134, K135, K136, K137} \\r
+ }\r
+\r
+#endif
\ No newline at end of file