summaryrefslogtreecommitdiff
path: root/keyboards/lets_split
diff options
context:
space:
mode:
authorIBNobody <ibnobody@gmail.com>2016-09-20 21:38:59 -0500
committerIBNobody <ibnobody@gmail.com>2016-09-20 21:38:59 -0500
commit6631abc1cb0e570271bcf33464e3af17b6fc0b87 (patch)
tree29e33041e54b98af1425740f1e6625091ffe50e8 /keyboards/lets_split
parentf956802f29aaa3da0d86d56f42986d456bae717b (diff)
Made Serial and I2C not include the Other
This saves 192 bytes
Diffstat (limited to 'keyboards/lets_split')
-rw-r--r--keyboards/lets_split/config.h7
-rw-r--r--keyboards/lets_split/i2c.c3
-rw-r--r--keyboards/lets_split/matrix.c23
-rw-r--r--keyboards/lets_split/rules.mk4
-rw-r--r--keyboards/lets_split/serial.c5
-rw-r--r--keyboards/lets_split/split_util.c8
6 files changed, 36 insertions, 14 deletions
diff --git a/keyboards/lets_split/config.h b/keyboards/lets_split/config.h
index ec99514aa3..f4d900accb 100644
--- a/keyboards/lets_split/config.h
+++ b/keyboards/lets_split/config.h
@@ -41,6 +41,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// #define USE_I2C
+// Use serial if not using I2C
+#ifndef USE_I2C
+# define USE_SERIAL
+#endif
+
// #define EE_HANDS
#define I2C_MASTER_LEFT
@@ -94,4 +99,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION
-#endif \ No newline at end of file
+#endif
diff --git a/keyboards/lets_split/i2c.c b/keyboards/lets_split/i2c.c
index c72789403e..084c890c40 100644
--- a/keyboards/lets_split/i2c.c
+++ b/keyboards/lets_split/i2c.c
@@ -6,6 +6,8 @@
#include <stdbool.h>
#include "i2c.h"
+#ifdef USE_I2C
+
// Limits the amount of we wait for any one i2c transaction.
// Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is
// 9 bits, a single transaction will take around 90μs to complete.
@@ -157,3 +159,4 @@ ISR(TWI_vect) {
// Reset everything, so we are ready for the next TWI interrupt
TWCR |= (1<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN);
}
+#endif
diff --git a/keyboards/lets_split/matrix.c b/keyboards/lets_split/matrix.c
index 1d768c59b3..1389690042 100644
--- a/keyboards/lets_split/matrix.c
+++ b/keyboards/lets_split/matrix.c
@@ -28,14 +28,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "debug.h"
#include "util.h"
#include "matrix.h"
-#include "i2c.h"
-#include "serial.h"
#include "split_util.h"
#include "pro_micro.h"
#include "config.h"
+#ifdef USE_I2C
+# include "i2c.h"
+#else // USE_SERIAL
+# include "serial.h"
+#endif
+
#ifndef DEBOUNCE
-# define DEBOUNCE 5
+# define DEBOUNCE 5
#endif
#define ERROR_DISCONNECT_COUNT 5
@@ -145,6 +149,8 @@ uint8_t _matrix_scan(void)
return 1;
}
+#ifdef USE_I2C
+
// Get rows from other half over i2c
int i2c_transaction(void) {
int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
@@ -176,7 +182,8 @@ i2c_error: // the cable is disconnceted, or something else went wrong
return 0;
}
-#ifndef USE_I2C
+#else // USE_SERIAL
+
int serial_transaction(void) {
int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
@@ -199,7 +206,7 @@ uint8_t matrix_scan(void)
#ifdef USE_I2C
if( i2c_transaction() ) {
-#else
+#else // USE_SERIAL
if( serial_transaction() ) {
#endif
// turn on the indicator led when halves are disconnected
@@ -235,7 +242,7 @@ void matrix_slave_scan(void) {
/* i2c_slave_buffer[i] = matrix[offset+i]; */
i2c_slave_buffer[i] = matrix[offset+i];
}
-#else
+#else // USE_SERIAL
for (int i = 0; i < ROWS_PER_HAND; ++i) {
serial_slave_buffer[i] = matrix[offset+i];
}
@@ -290,7 +297,7 @@ static void init_cols(void)
static matrix_row_t read_cols(void)
{
matrix_row_t result = 0;
- for(int x = 0; x < MATRIX_COLS; x++) {
+ for(int x = 0; x < MATRIX_COLS; x++) {
result |= (_SFR_IO8(col_pins[x] >> 4) & _BV(col_pins[x] & 0xF)) ? 0 : (1 << x);
}
return result;
@@ -298,7 +305,7 @@ static matrix_row_t read_cols(void)
static void unselect_rows(void)
{
- for(int x = 0; x < ROWS_PER_HAND; x++) {
+ for(int x = 0; x < ROWS_PER_HAND; x++) {
_SFR_IO8((row_pins[x] >> 4) + 1) &= ~_BV(row_pins[x] & 0xF);
_SFR_IO8((row_pins[x] >> 4) + 2) |= _BV(row_pins[x] & 0xF);
}
diff --git a/keyboards/lets_split/rules.mk b/keyboards/lets_split/rules.mk
index 6961fbd556..6fde8a444c 100644
--- a/keyboards/lets_split/rules.mk
+++ b/keyboards/lets_split/rules.mk
@@ -52,7 +52,7 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
OPT_DEFS += -DBOOTLOADER_SIZE=4096
# Build Options
-# change to "no" to disable the options, or define them in the Makefile in
+# 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)
@@ -71,4 +71,4 @@ RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight. Do not enable this
# 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 \ No newline at end of file
+CUSTOM_MATRIX = yes
diff --git a/keyboards/lets_split/serial.c b/keyboards/lets_split/serial.c
index f439c2f20b..6faed09ce0 100644
--- a/keyboards/lets_split/serial.c
+++ b/keyboards/lets_split/serial.c
@@ -10,9 +10,10 @@
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdbool.h>
-
#include "serial.h"
+#ifdef USE_SERIAL
+
// Serial pulse period in microseconds. Its probably a bad idea to lower this
// value.
#define SERIAL_DELAY 24
@@ -223,3 +224,5 @@ int serial_update_buffers(void) {
sei();
return 0;
}
+
+#endif
diff --git a/keyboards/lets_split/split_util.c b/keyboards/lets_split/split_util.c
index 65003a71a4..461921798f 100644
--- a/keyboards/lets_split/split_util.c
+++ b/keyboards/lets_split/split_util.c
@@ -6,11 +6,15 @@
#include <avr/eeprom.h>
#include "split_util.h"
#include "matrix.h"
-#include "i2c.h"
-#include "serial.h"
#include "keyboard.h"
#include "config.h"
+#ifdef USE_I2C
+# include "i2c.h"
+#else
+# include "serial.h"
+#endif
+
volatile bool isLeftHand = true;
static void setup_handedness(void) {