diff options
| author | IBNobody <ibnobody@gmail.com> | 2016-09-20 21:38:59 -0500 |
|---|---|---|
| committer | IBNobody <ibnobody@gmail.com> | 2016-09-20 21:38:59 -0500 |
| commit | 6631abc1cb0e570271bcf33464e3af17b6fc0b87 (patch) | |
| tree | 29e33041e54b98af1425740f1e6625091ffe50e8 | |
| parent | f956802f29aaa3da0d86d56f42986d456bae717b (diff) | |
| download | qmk_firmware-6631abc1cb0e570271bcf33464e3af17b6fc0b87.tar.gz qmk_firmware-6631abc1cb0e570271bcf33464e3af17b6fc0b87.zip | |
Made Serial and I2C not include the Other
This saves 192 bytes
| -rw-r--r-- | keyboards/lets_split/config.h | 7 | ||||
| -rw-r--r-- | keyboards/lets_split/i2c.c | 3 | ||||
| -rw-r--r-- | keyboards/lets_split/matrix.c | 23 | ||||
| -rw-r--r-- | keyboards/lets_split/rules.mk | 4 | ||||
| -rw-r--r-- | keyboards/lets_split/serial.c | 5 | ||||
| -rw-r--r-- | keyboards/lets_split/split_util.c | 8 |
6 files changed, 36 insertions, 14 deletions
diff --git a/keyboards/lets_split/config.h b/keyboards/lets_split/config.h index ec99514aa..f4d900acc 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/>. | |||
| 41 | 41 | ||
| 42 | // #define USE_I2C | 42 | // #define USE_I2C |
| 43 | 43 | ||
| 44 | // Use serial if not using I2C | ||
| 45 | #ifndef USE_I2C | ||
| 46 | # define USE_SERIAL | ||
| 47 | #endif | ||
| 48 | |||
| 44 | // #define EE_HANDS | 49 | // #define EE_HANDS |
| 45 | 50 | ||
| 46 | #define I2C_MASTER_LEFT | 51 | #define I2C_MASTER_LEFT |
| @@ -94,4 +99,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 94 | //#define NO_ACTION_MACRO | 99 | //#define NO_ACTION_MACRO |
| 95 | //#define NO_ACTION_FUNCTION | 100 | //#define NO_ACTION_FUNCTION |
| 96 | 101 | ||
| 97 | #endif \ No newline at end of file | 102 | #endif |
diff --git a/keyboards/lets_split/i2c.c b/keyboards/lets_split/i2c.c index c72789403..084c890c4 100644 --- a/keyboards/lets_split/i2c.c +++ b/keyboards/lets_split/i2c.c | |||
| @@ -6,6 +6,8 @@ | |||
| 6 | #include <stdbool.h> | 6 | #include <stdbool.h> |
| 7 | #include "i2c.h" | 7 | #include "i2c.h" |
| 8 | 8 | ||
| 9 | #ifdef USE_I2C | ||
| 10 | |||
| 9 | // Limits the amount of we wait for any one i2c transaction. | 11 | // Limits the amount of we wait for any one i2c transaction. |
| 10 | // Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is | 12 | // Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is |
| 11 | // 9 bits, a single transaction will take around 90μs to complete. | 13 | // 9 bits, a single transaction will take around 90μs to complete. |
| @@ -157,3 +159,4 @@ ISR(TWI_vect) { | |||
| 157 | // Reset everything, so we are ready for the next TWI interrupt | 159 | // Reset everything, so we are ready for the next TWI interrupt |
| 158 | TWCR |= (1<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN); | 160 | TWCR |= (1<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN); |
| 159 | } | 161 | } |
| 162 | #endif | ||
diff --git a/keyboards/lets_split/matrix.c b/keyboards/lets_split/matrix.c index 1d768c59b..138969004 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/>. | |||
| 28 | #include "debug.h" | 28 | #include "debug.h" |
| 29 | #include "util.h" | 29 | #include "util.h" |
| 30 | #include "matrix.h" | 30 | #include "matrix.h" |
| 31 | #include "i2c.h" | ||
| 32 | #include "serial.h" | ||
| 33 | #include "split_util.h" | 31 | #include "split_util.h" |
| 34 | #include "pro_micro.h" | 32 | #include "pro_micro.h" |
| 35 | #include "config.h" | 33 | #include "config.h" |
| 36 | 34 | ||
| 35 | #ifdef USE_I2C | ||
| 36 | # include "i2c.h" | ||
| 37 | #else // USE_SERIAL | ||
| 38 | # include "serial.h" | ||
| 39 | #endif | ||
| 40 | |||
| 37 | #ifndef DEBOUNCE | 41 | #ifndef DEBOUNCE |
| 38 | # define DEBOUNCE 5 | 42 | # define DEBOUNCE 5 |
| 39 | #endif | 43 | #endif |
| 40 | 44 | ||
| 41 | #define ERROR_DISCONNECT_COUNT 5 | 45 | #define ERROR_DISCONNECT_COUNT 5 |
| @@ -145,6 +149,8 @@ uint8_t _matrix_scan(void) | |||
| 145 | return 1; | 149 | return 1; |
| 146 | } | 150 | } |
| 147 | 151 | ||
| 152 | #ifdef USE_I2C | ||
| 153 | |||
| 148 | // Get rows from other half over i2c | 154 | // Get rows from other half over i2c |
| 149 | int i2c_transaction(void) { | 155 | int i2c_transaction(void) { |
| 150 | int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; | 156 | int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; |
| @@ -176,7 +182,8 @@ i2c_error: // the cable is disconnceted, or something else went wrong | |||
| 176 | return 0; | 182 | return 0; |
| 177 | } | 183 | } |
| 178 | 184 | ||
| 179 | #ifndef USE_I2C | 185 | #else // USE_SERIAL |
| 186 | |||
| 180 | int serial_transaction(void) { | 187 | int serial_transaction(void) { |
| 181 | int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; | 188 | int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; |
| 182 | 189 | ||
| @@ -199,7 +206,7 @@ uint8_t matrix_scan(void) | |||
| 199 | 206 | ||
| 200 | #ifdef USE_I2C | 207 | #ifdef USE_I2C |
| 201 | if( i2c_transaction() ) { | 208 | if( i2c_transaction() ) { |
| 202 | #else | 209 | #else // USE_SERIAL |
| 203 | if( serial_transaction() ) { | 210 | if( serial_transaction() ) { |
| 204 | #endif | 211 | #endif |
| 205 | // turn on the indicator led when halves are disconnected | 212 | // turn on the indicator led when halves are disconnected |
| @@ -235,7 +242,7 @@ void matrix_slave_scan(void) { | |||
| 235 | /* i2c_slave_buffer[i] = matrix[offset+i]; */ | 242 | /* i2c_slave_buffer[i] = matrix[offset+i]; */ |
| 236 | i2c_slave_buffer[i] = matrix[offset+i]; | 243 | i2c_slave_buffer[i] = matrix[offset+i]; |
| 237 | } | 244 | } |
| 238 | #else | 245 | #else // USE_SERIAL |
| 239 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | 246 | for (int i = 0; i < ROWS_PER_HAND; ++i) { |
| 240 | serial_slave_buffer[i] = matrix[offset+i]; | 247 | serial_slave_buffer[i] = matrix[offset+i]; |
| 241 | } | 248 | } |
| @@ -290,7 +297,7 @@ static void init_cols(void) | |||
| 290 | static matrix_row_t read_cols(void) | 297 | static matrix_row_t read_cols(void) |
| 291 | { | 298 | { |
| 292 | matrix_row_t result = 0; | 299 | matrix_row_t result = 0; |
| 293 | for(int x = 0; x < MATRIX_COLS; x++) { | 300 | for(int x = 0; x < MATRIX_COLS; x++) { |
| 294 | result |= (_SFR_IO8(col_pins[x] >> 4) & _BV(col_pins[x] & 0xF)) ? 0 : (1 << x); | 301 | result |= (_SFR_IO8(col_pins[x] >> 4) & _BV(col_pins[x] & 0xF)) ? 0 : (1 << x); |
| 295 | } | 302 | } |
| 296 | return result; | 303 | return result; |
| @@ -298,7 +305,7 @@ static matrix_row_t read_cols(void) | |||
| 298 | 305 | ||
| 299 | static void unselect_rows(void) | 306 | static void unselect_rows(void) |
| 300 | { | 307 | { |
| 301 | for(int x = 0; x < ROWS_PER_HAND; x++) { | 308 | for(int x = 0; x < ROWS_PER_HAND; x++) { |
| 302 | _SFR_IO8((row_pins[x] >> 4) + 1) &= ~_BV(row_pins[x] & 0xF); | 309 | _SFR_IO8((row_pins[x] >> 4) + 1) &= ~_BV(row_pins[x] & 0xF); |
| 303 | _SFR_IO8((row_pins[x] >> 4) + 2) |= _BV(row_pins[x] & 0xF); | 310 | _SFR_IO8((row_pins[x] >> 4) + 2) |= _BV(row_pins[x] & 0xF); |
| 304 | } | 311 | } |
diff --git a/keyboards/lets_split/rules.mk b/keyboards/lets_split/rules.mk index 6961fbd55..6fde8a444 100644 --- a/keyboards/lets_split/rules.mk +++ b/keyboards/lets_split/rules.mk | |||
| @@ -52,7 +52,7 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | |||
| 52 | OPT_DEFS += -DBOOTLOADER_SIZE=4096 | 52 | OPT_DEFS += -DBOOTLOADER_SIZE=4096 |
| 53 | 53 | ||
| 54 | # Build Options | 54 | # Build Options |
| 55 | # change to "no" to disable the options, or define them in the Makefile in | 55 | # change to "no" to disable the options, or define them in the Makefile in |
| 56 | # the appropriate keymap folder that will get included automatically | 56 | # the appropriate keymap folder that will get included automatically |
| 57 | # | 57 | # |
| 58 | BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000) | 58 | BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000) |
| @@ -71,4 +71,4 @@ RGBLIGHT_ENABLE ?= no # Enable WS2812 RGB underlight. Do not enable this | |||
| 71 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 71 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
| 72 | SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend | 72 | SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend |
| 73 | 73 | ||
| 74 | CUSTOM_MATRIX = yes \ No newline at end of file | 74 | CUSTOM_MATRIX = yes |
diff --git a/keyboards/lets_split/serial.c b/keyboards/lets_split/serial.c index f439c2f20..6faed09ce 100644 --- a/keyboards/lets_split/serial.c +++ b/keyboards/lets_split/serial.c | |||
| @@ -10,9 +10,10 @@ | |||
| 10 | #include <avr/interrupt.h> | 10 | #include <avr/interrupt.h> |
| 11 | #include <util/delay.h> | 11 | #include <util/delay.h> |
| 12 | #include <stdbool.h> | 12 | #include <stdbool.h> |
| 13 | |||
| 14 | #include "serial.h" | 13 | #include "serial.h" |
| 15 | 14 | ||
| 15 | #ifdef USE_SERIAL | ||
| 16 | |||
| 16 | // Serial pulse period in microseconds. Its probably a bad idea to lower this | 17 | // Serial pulse period in microseconds. Its probably a bad idea to lower this |
| 17 | // value. | 18 | // value. |
| 18 | #define SERIAL_DELAY 24 | 19 | #define SERIAL_DELAY 24 |
| @@ -223,3 +224,5 @@ int serial_update_buffers(void) { | |||
| 223 | sei(); | 224 | sei(); |
| 224 | return 0; | 225 | return 0; |
| 225 | } | 226 | } |
| 227 | |||
| 228 | #endif | ||
diff --git a/keyboards/lets_split/split_util.c b/keyboards/lets_split/split_util.c index 65003a71a..461921798 100644 --- a/keyboards/lets_split/split_util.c +++ b/keyboards/lets_split/split_util.c | |||
| @@ -6,11 +6,15 @@ | |||
| 6 | #include <avr/eeprom.h> | 6 | #include <avr/eeprom.h> |
| 7 | #include "split_util.h" | 7 | #include "split_util.h" |
| 8 | #include "matrix.h" | 8 | #include "matrix.h" |
| 9 | #include "i2c.h" | ||
| 10 | #include "serial.h" | ||
| 11 | #include "keyboard.h" | 9 | #include "keyboard.h" |
| 12 | #include "config.h" | 10 | #include "config.h" |
| 13 | 11 | ||
| 12 | #ifdef USE_I2C | ||
| 13 | # include "i2c.h" | ||
| 14 | #else | ||
| 15 | # include "serial.h" | ||
| 16 | #endif | ||
| 17 | |||
| 14 | volatile bool isLeftHand = true; | 18 | volatile bool isLeftHand = true; |
| 15 | 19 | ||
| 16 | static void setup_handedness(void) { | 20 | static void setup_handedness(void) { |
