diff options
author | Salicylic-acid3 <46864619+Salicylic-acid3@users.noreply.github.com> | 2019-10-23 02:54:53 +0900 |
---|---|---|
committer | Drashna Jaelre <drashna@live.com> | 2019-10-22 10:54:53 -0700 |
commit | 737bca8e5134086dd52eb4ec6ca5ca034e9c5bd9 (patch) | |
tree | 9ce6a1e958c77bd01ca7026750ebb133c34060ea /keyboards/naked60/rev1 | |
parent | d99f6e95e15075ecab28090e1361e2581b70a517 (diff) | |
download | qmk_firmware-737bca8e5134086dd52eb4ec6ca5ca034e9c5bd9.tar.gz qmk_firmware-737bca8e5134086dd52eb4ec6ca5ca034e9c5bd9.zip |
[Keyboard] Keyboard Naked60 Update (#7106)
* [Keyboard] Keyboard Naked60 Update
Support for SPLIT_KEYBOARD
Keymap updates
* Update keyboards/naked60/readme.md
Co-Authored-By: Joel Challis <git@zvecr.com>
* Update keyboards/naked60/rev1/config.h
Co-Authored-By: Joel Challis <git@zvecr.com>
* Update keyboards/naked60/rev1/rev1.h
Co-Authored-By: Joel Challis <git@zvecr.com>
* Update keyboards/naked60/rev1/rev1.h
Co-Authored-By: Joel Challis <git@zvecr.com>
Diffstat (limited to 'keyboards/naked60/rev1')
-rw-r--r-- | keyboards/naked60/rev1/config.h | 92 | ||||
-rw-r--r-- | keyboards/naked60/rev1/matrix.c | 357 | ||||
-rw-r--r-- | keyboards/naked60/rev1/rev1.c | 6 | ||||
-rw-r--r-- | keyboards/naked60/rev1/rev1.h | 45 | ||||
-rw-r--r-- | keyboards/naked60/rev1/rules.mk | 3 | ||||
-rw-r--r-- | keyboards/naked60/rev1/serial_config.h | 8 | ||||
-rw-r--r-- | keyboards/naked60/rev1/serial_config_simpleapi.h | 8 | ||||
-rw-r--r-- | keyboards/naked60/rev1/split_scomm.c | 92 | ||||
-rw-r--r-- | keyboards/naked60/rev1/split_scomm.h | 22 | ||||
-rw-r--r-- | keyboards/naked60/rev1/split_util.c | 70 | ||||
-rw-r--r-- | keyboards/naked60/rev1/split_util.h | 16 |
11 files changed, 38 insertions, 681 deletions
diff --git a/keyboards/naked60/rev1/config.h b/keyboards/naked60/rev1/config.h index 1724ef060a..ac0c0ab2fc 100644 --- a/keyboards/naked60/rev1/config.h +++ b/keyboards/naked60/rev1/config.h @@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #pragma once + /* USB Device descriptor parameter */ #define VENDOR_ID 0xFEED #define PRODUCT_ID 0x3060 @@ -26,94 +27,27 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define PRODUCT naked60 #define DESCRIPTION Ortholinear 60 Keys Keyboard -/* Use I2C or Serial */ -//#define USE_I2C -#define USE_SERIAL -//#define USE_MATRIX_I2C - -/* Select hand configuration */ -#define MASTER_LEFT -// #define MASTER_RIGHT -// #define EE_HANDS - -// OLED support -// see ./rules.mk: OLED_ENABLE=yes or no -#ifdef OLED_ENABLE - #define SSD1306OLED -#endif - /* key matrix size */ #define MATRIX_ROWS 10 -#define MATRIX_COLS 14 +#define MATRIX_COLS 12 // Rows are doubled-up #define MATRIX_ROW_PINS { B6, D1, D0, D4, C6 } - -// wiring of each half #define MATRIX_COL_PINS { F4, F5, F6, F7, B1, B3, B2, D7, E6, B4, B5, D3 } -// #define MATRIX_COL_PINS { D3, B5, B4, E6, D7, B2, B3, B1, F7, F6, F5, F4 } //uncomment this line and comment line above if you need to reverse left-to-right key order - -/* define if matrix has ghost */ -//#define MATRIX_HAS_GHOST - -/* number of backlight levels */ -// #define BACKLIGHT_LEVELS 3 +// When using Setta21 +#define MATRIX_ROW_PINS_RIGHT { D4, C6, D7, E6, B2 } +#define MATRIX_COL_PINS_RIGHT { F4, F5, F6, F7, B1, B3, B2, B6, B4, B5, B2, B2 } +// When using Nafuda +//#define MATRIX_ROW_PINS_RIGHT { D1, D0, D4, C6, B6 } +//#define MATRIX_COL_PINS_RIGHT { F4, F5, F6, F7, B1, B3, B2, D7, E6, B4, B5, D3 } /* Set 0 if debouncing isn't needed */ #define DEBOUNCE 5 +/* serial.c configuration for split keyboard */ +#define SOFT_SERIAL_PIN D2 + /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ -//#define LOCKING_SUPPORT_ENABLE +#define LOCKING_SUPPORT_ENABLE /* Locking resynchronize hack */ -//#define LOCKING_RESYNC_ENABLE - -/* ws2812 RGB LED */ -#define RGB_DI_PIN D3 -#define RGBLIGHT_TIMER - -// naked60 keyboard RGB LED support -//#define RGBLIGHT_ANIMATIONS : see ./rules.mk: LED_ANIMATIONS = yes or no -// see ./rules.mk: LED_BACK_ENABLE or LED_UNDERGLOW_ENABLE set yes -//#define RGBLED_NUM 21 - -#ifndef IOS_DEVICE_ENABLE - #define RGBLIGHT_LIMIT_VAL 180 - #define RGBLIGHT_VAL_STEP 17 -#else - #define RGBLIGHT_LIMIT_VAL 50 - #define RGBLIGHT_VAL_STEP 4 -#endif -#define RGBLIGHT_HUE_STEP 10 -#define RGBLIGHT_SAT_STEP 17 - -#if defined(RGBLIGHT_ENABLE) && !defined(IOS_DEVICE_ENABLE) -// USB_MAX_POWER_CONSUMPTION value for naked60 keyboard -// 120 RGBoff, OLEDoff -// 120 OLED -// 330 RGB 6 -// 300 RGB 32 -// 310 OLED & RGB 32 - #define USB_MAX_POWER_CONSUMPTION 400 -#else - // fix iPhone and iPad power adapter issue - // iOS device need lessthan 100 - #define USB_MAX_POWER_CONSUMPTION 100 -#endif - -/* - * Feature disable options - * These options are also useful to firmware size reduction. - */ - -/* disable debug print */ -// #define NO_DEBUG - -/* disable print */ -// #define NO_PRINT - -/* disable action features */ -//#define NO_ACTION_LAYER -//#define NO_ACTION_TAPPING -//#define NO_ACTION_ONESHOT -//#define NO_ACTION_MACRO -//#define NO_ACTION_FUNCTION +#define LOCKING_RESYNC_ENABLE diff --git a/keyboards/naked60/rev1/matrix.c b/keyboards/naked60/rev1/matrix.c deleted file mode 100644 index 8685a8125e..0000000000 --- a/keyboards/naked60/rev1/matrix.c +++ /dev/null @@ -1,357 +0,0 @@ -/* -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/>. -*/ - -/* - * scan matrix - */ -#include <stdint.h> -#include <stdbool.h> -#include <string.h> -#include <avr/io.h> -#include <avr/wdt.h> -#include <avr/interrupt.h> -#include <util/delay.h> -#include "print.h" -#include "debug.h" -#include "util.h" -#include "matrix.h" -#include "split_util.h" -#include "pro_micro.h" - -#ifdef USE_MATRIX_I2C -# include "i2c.h" -#else // USE_SERIAL -# include "split_scomm.h" -#endif - -#ifndef DEBOUNCE -# define DEBOUNCE 5 -#endif - -#define ERROR_DISCONNECT_COUNT 5 - -static uint8_t debouncing = DEBOUNCE; -static const int ROWS_PER_HAND = MATRIX_ROWS/2; -static uint8_t error_count = 0; -uint8_t is_master = 0 ; - -static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; -static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; - -/* matrix state(1:on, 0:off) */ -static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; - -static matrix_row_t read_cols(void); -static void init_cols(void); -static void unselect_rows(void); -static void select_row(uint8_t row); -static uint8_t matrix_master_scan(void); - - -__attribute__ ((weak)) -void matrix_init_kb(void) { - matrix_init_user(); -} - -__attribute__ ((weak)) -void matrix_scan_kb(void) { - matrix_scan_user(); -} - -__attribute__ ((weak)) -void matrix_init_user(void) { -} - -__attribute__ ((weak)) -void matrix_scan_user(void) { -} - -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} - -void matrix_init(void) -{ - debug_enable = true; - debug_matrix = true; - debug_mouse = true; - // initialize row and col - unselect_rows(); - init_cols(); - - TX_RX_LED_INIT; - TXLED0; - RXLED0; - - // initialize matrix state: all keys off - for (uint8_t i=0; i < MATRIX_ROWS; i++) { - matrix[i] = 0; - matrix_debouncing[i] = 0; - } - - is_master = has_usb(); - - matrix_init_quantum(); -} - -uint8_t _matrix_scan(void) -{ - // Right hand is stored after the left in the matirx so, we need to offset it - int offset = isLeftHand ? 0 : (ROWS_PER_HAND); - - for (uint8_t i = 0; i < ROWS_PER_HAND; i++) { - select_row(i); - _delay_us(30); // without this wait read unstable value. - matrix_row_t cols = read_cols(); - if (matrix_debouncing[i+offset] != cols) { - matrix_debouncing[i+offset] = cols; - debouncing = DEBOUNCE; - } - unselect_rows(); - } - - if (debouncing) { - if (--debouncing) { - _delay_ms(1); - } else { - for (uint8_t i = 0; i < ROWS_PER_HAND; i++) { - matrix[i+offset] = matrix_debouncing[i+offset]; - } - } - } - - return 1; -} - -#ifdef USE_MATRIX_I2C - -// Get rows from other half over i2c -int i2c_transaction(void) { - int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; - - int err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE); - if (err) goto i2c_error; - - // start of matrix stored at 0x00 - err = i2c_master_write(0x00); - if (err) goto i2c_error; - - // Start read - err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ); - if (err) goto i2c_error; - - if (!err) { - int i; - for (i = 0; i < ROWS_PER_HAND-1; ++i) { - matrix[slaveOffset+i] = i2c_master_read(I2C_ACK); - } - matrix[slaveOffset+i] = i2c_master_read(I2C_NACK); - i2c_master_stop(); - } else { -i2c_error: // the cable is disconnceted, or something else went wrong - i2c_reset_state(); - return err; - } - - return 0; -} - -#else // USE_SERIAL - -int serial_transaction(int master_changed) { - int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; -#ifdef SERIAL_USE_MULTI_TRANSACTION - int ret=serial_update_buffers(master_changed); -#else - int ret=serial_update_buffers(); -#endif - if (ret ) { - if(ret==2) RXLED1; - return 1; - } - RXLED0; - memcpy(&matrix[slaveOffset], - (void *)serial_slave_buffer, sizeof(serial_slave_buffer)); - return 0; -} -#endif - -uint8_t matrix_scan(void) -{ - if (is_master) { - matrix_master_scan(); - }else{ - matrix_slave_scan(); - int offset = (isLeftHand) ? ROWS_PER_HAND : 0; - memcpy(&matrix[offset], - (void *)serial_master_buffer, sizeof(serial_master_buffer)); - matrix_scan_quantum(); - } - return 1; -} - - -uint8_t matrix_master_scan(void) { - - int ret = _matrix_scan(); - int mchanged = 1; - - int offset = (isLeftHand) ? 0 : ROWS_PER_HAND; - -#ifdef USE_MATRIX_I2C -// for (int i = 0; i < ROWS_PER_HAND; ++i) { - /* i2c_slave_buffer[i] = matrix[offset+i]; */ -// i2c_slave_buffer[i] = matrix[offset+i]; -// } -#else // USE_SERIAL - #ifdef SERIAL_USE_MULTI_TRANSACTION - mchanged = memcmp((void *)serial_master_buffer, - &matrix[offset], sizeof(serial_master_buffer)); - #endif - memcpy((void *)serial_master_buffer, - &matrix[offset], sizeof(serial_master_buffer)); -#endif - -#ifdef USE_MATRIX_I2C - if( i2c_transaction() ) { -#else // USE_SERIAL - if( serial_transaction(mchanged) ) { -#endif - // turn on the indicator led when halves are disconnected - TXLED1; - - error_count++; - - if (error_count > ERROR_DISCONNECT_COUNT) { - // reset other half if disconnected - int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; - for (int i = 0; i < ROWS_PER_HAND; ++i) { - matrix[slaveOffset+i] = 0; - } - } - } else { - // turn off the indicator led on no error - TXLED0; - error_count = 0; - } - matrix_scan_quantum(); - return ret; -} - -void matrix_slave_scan(void) { - _matrix_scan(); - - int offset = (isLeftHand) ? 0 : ROWS_PER_HAND; - -#ifdef USE_MATRIX_I2C - for (int i = 0; i < ROWS_PER_HAND; ++i) { - /* i2c_slave_buffer[i] = matrix[offset+i]; */ - i2c_slave_buffer[i] = matrix[offset+i]; - } -#else // USE_SERIAL - #ifdef SERIAL_USE_MULTI_TRANSACTION - int change = 0; - #endif - for (int i = 0; i < ROWS_PER_HAND; ++i) { - #ifdef SERIAL_USE_MULTI_TRANSACTION - if( serial_slave_buffer[i] != matrix[offset+i] ) - change = 1; - #endif - serial_slave_buffer[i] = matrix[offset+i]; - } - #ifdef SERIAL_USE_MULTI_TRANSACTION - slave_buffer_change_count += change; - #endif -#endif -} - -bool matrix_is_modified(void) -{ - if (debouncing) return false; - return true; -} - -inline -bool matrix_is_on(uint8_t row, uint8_t col) -{ - return (matrix[row] & ((matrix_row_t)1<<col)); -} - -inline -matrix_row_t matrix_get_row(uint8_t row) -{ - return matrix[row]; -} - -void matrix_print(void) -{ - print("\nr/c 0123456789ABCDEF\n"); - for (uint8_t row = 0; row < MATRIX_ROWS; row++) { - phex(row); print(": "); - pbin_reverse16(matrix_get_row(row)); - print("\n"); - } -} - -uint8_t matrix_key_count(void) -{ - uint8_t count = 0; - for (uint8_t i = 0; i < MATRIX_ROWS; i++) { - count += bitpop16(matrix[i]); - } - return count; -} - -static void init_cols(void) -{ - for(int x = 0; x < MATRIX_COLS; x++) { - _SFR_IO8((col_pins[x] >> 4) + 1) &= ~_BV(col_pins[x] & 0xF); - _SFR_IO8((col_pins[x] >> 4) + 2) |= _BV(col_pins[x] & 0xF); - } -} - -static matrix_row_t read_cols(void) -{ - matrix_row_t result = 0; - 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; -} - -static void unselect_rows(void) -{ - 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); - } -} - -static void select_row(uint8_t row) -{ - _SFR_IO8((row_pins[row] >> 4) + 1) |= _BV(row_pins[row] & 0xF); - _SFR_IO8((row_pins[row] >> 4) + 2) &= ~_BV(row_pins[row] & 0xF); -} diff --git a/keyboards/naked60/rev1/rev1.c b/keyboards/naked60/rev1/rev1.c index 520a869e57..bce48f89c3 100644 --- a/keyboards/naked60/rev1/rev1.c +++ b/keyboards/naked60/rev1/rev1.c @@ -1 +1,5 @@ -#include "rev1.h" +#include "naked60.h" + +void matrix_init_kb(void) { + matrix_init_user(); +}; diff --git a/keyboards/naked60/rev1/rev1.h b/keyboards/naked60/rev1/rev1.h index 38e355cfcf..d8ee83c470 100644 --- a/keyboards/naked60/rev1/rev1.h +++ b/keyboards/naked60/rev1/rev1.h @@ -4,11 +4,6 @@ #include "quantum.h" -#ifdef RGBLIGHT_ENABLE -//rgb led driver -#include "ws2812.h" -#endif - ////////////////////////////////////////////////////////////////////////////// // When only use naked60. @@ -59,16 +54,16 @@ L40, L41, L42, L43, L44, L45, L46, L47, L48, L49, L4A, L4B \ ) \ { \ - { L00, L01, L02, L03, L04, L05, L06, L07, L08, L09, L0A, L0B,KC_NO,KC_NO }, \ - { L10, L11, L12, L13, L14, L15, L16, L17, L18, L19, L1A, L1B,KC_NO,KC_NO }, \ - { L20, L21, L22, L23, L24, L25, L26, L27, L28, L29, L2A, L2B,KC_NO,KC_NO }, \ - { L30, L31, L32, L33, L34, L35, L36, L37, L38, L39, L3A, L3B,KC_NO,KC_NO }, \ - { L40, L41, L42, L43, L44, L45, L46, L47, L48, L49, L4A, L4B,KC_NO,KC_NO }, \ - { R00, R01, R02, R03, R04, R05,KC_NO,KC_NO,KC_NO, R11, R12, R13, R14, R15 }, \ - { R20, R21, R22, R23, R24, R25,KC_NO,KC_NO, R30,KC_NO, R32,KC_NO, R34, R35 }, \ - {KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO }, \ - {KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO }, \ - {KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO } \ + { L00, L01, L02, L03, L04, L05, L06, L07, L08, L09, L0A, L0B }, \ + { L10, L11, L12, L13, L14, L15, L16, L17, L18, L19, L1A, L1B }, \ + { L20, L21, L22, L23, L24, L25, L26, L27, L28, L29, L2A, L2B }, \ + { L30, L31, L32, L33, L34, L35, L36, L37, L38, L39, L3A, L3B }, \ + { L40, L41, L42, L43, L44, L45, L46, L47, L48, L49, L4A, L4B }, \ + { R00, R01, R02, R03, R04, R05,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO }, \ + {KC_NO, R11, R12, R13, R14, R15,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO }, \ + { R20, R21, R22, R23, R24, R25,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO }, \ + { R30,KC_NO, R32,KC_NO, R34, R35,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO }, \ + {KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO } \ } ////////////////////////////////////////////////////////////////////////////// @@ -83,15 +78,15 @@ L40, L41, L42, L43, L44, L45, L46, L47, L48, L49, L4A, L4B \ ) \ { \ - { L00, L01, L02, L03, L04, L05, L06, L07, L08, L09, L0A, L0B,KC_NO,KC_NO }, \ - { L10, L11, L12, L13, L14, L15, L16, L17, L18, L19, L1A, L1B,KC_NO,KC_NO }, \ - { L20, L21, L22, L23, L24, L25, L26, L27, L28, L29, L2A, L2B,KC_NO,KC_NO }, \ - { L30, L31, L32, L33, L34, L35, L36, L37, L38, L39, L3A, L3B,KC_NO,KC_NO }, \ - { L40, L41, L42, L43, L44, L45, L46, L47, L48, L49, L4A, L4B,KC_NO,KC_NO }, \ - {KC_NO, R01,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO, R10, R11, R12,KC_NO,KC_NO,KC_NO }, \ - { R20, R21, R22,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO }, \ - {KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO }, \ - {KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO }, \ - {KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO } \ + { L00, L01, L02, L03, L04, L05, L06, L07, L08, L09, L0A, L0B }, \ + { L10, L11, L12, L13, L14, L15, L16, L17, L18, L19, L1A, L1B }, \ + { L20, L21, L22, L23, L24, L25, L26, L27, L28, L29, L2A, L2B }, \ + { L30, L31, L32, L33, L34, L35, L36, L37, L38, L39, L3A, L3B }, \ + { L40, L41, L42, L43, L44, L45, L46, L47, L48, L49, L4A, L4B }, \ + {KC_NO, R01,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO }, \ + { R10, R11, R12,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO }, \ + { R20, R21, R22,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO }, \ + {KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO }, \ + {KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO } \ } diff --git a/keyboards/naked60/rev1/rules.mk b/keyboards/naked60/rev1/rules.mk index a711810333..e69de29bb2 100644 --- a/keyboards/naked60/rev1/rules.mk +++ b/keyboards/naked60/rev1/rules.mk @@ -1,3 +0,0 @@ -SRC += matrix.c \ - split_util.c \ - split_scomm.c diff --git a/keyboards/naked60/rev1/serial_config.h b/keyboards/naked60/rev1/serial_config.h deleted file mode 100644 index 37135213d5..0000000000 --- a/keyboards/naked60/rev1/serial_config.h +++ /dev/null @@ -1,8 +0,0 @@ -//// #error rev2 serial config - -#ifndef SOFT_SERIAL_PIN -/* Soft Serial defines */ -#define SOFT_SERIAL_PIN D2 - -#define SERIAL_USE_MULTI_TRANSACTION -#endif diff --git a/keyboards/naked60/rev1/serial_config_simpleapi.h b/keyboards/naked60/rev1/serial_config_simpleapi.h deleted file mode 100644 index e2d22a41e7..0000000000 --- a/keyboards/naked60/rev1/serial_config_simpleapi.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef SERIAL_CONFIG_SIMPLEAPI_H -#define SERIAL_CONFIG_SIMPLEAPI_H - -#undef SERIAL_USE_MULTI_TRANSACTION -#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2 -#define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2 - -#endif // SERIAL_CONFIG_SIMPLEAPI_H diff --git a/keyboards/naked60/rev1/split_scomm.c b/keyboards/naked60/rev1/split_scomm.c deleted file mode 100644 index ada7867960..0000000000 --- a/keyboards/naked60/rev1/split_scomm.c +++ /dev/null @@ -1,92 +0,0 @@ -#ifdef USE_SERIAL -#ifdef SERIAL_USE_MULTI_TRANSACTION -/* --- USE flexible API (using multi-type transaction function) --- */ - -#include <stdbool.h> -#include <stdint.h> -#include <stddef.h> -#include <split_scomm.h> -#include "serial.h" -#ifdef CONSOLE_ENABLE - #include <print.h> -#endif - -uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0}; -uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0}; -uint8_t volatile status_com = 0; -uint8_t volatile status1 = 0; -uint8_t slave_buffer_change_count = 0; -uint8_t s_change_old = 0xff; -uint8_t s_change_new = 0xff; - -SSTD_t transactions[] = { -#define GET_SLAVE_STATUS 0 - /* master buffer not changed, only recive slave_buffer_change_count */ - { (uint8_t *)&status_com, - 0, NULL, - sizeof(slave_buffer_change_count), &slave_buffer_change_count, - }, -#define PUT_MASTER_GET_SLAVE_STATUS 1 - /* master buffer changed need send, and recive slave_buffer_change_count */ - { (uint8_t *)&status_com, - sizeof(serial_master_buffer), (uint8_t *)serial_master_buffer, - sizeof(slave_buffer_change_count), &slave_buffer_change_count, - }, -#define GET_SLAVE_BUFFER 2 - /* recive serial_slave_buffer */ - { (uint8_t *)&status1, - 0, NULL, - sizeof(serial_slave_buffer), (uint8_t *)serial_slave_buffer - } -}; - -void serial_master_init(void) -{ - soft_serial_initiator_init(transactions, TID_LIMIT(transactions)); -} - -void serial_slave_init(void) -{ - soft_serial_target_init(transactions, TID_LIMIT(transactions)); -} - -// 0 => no error -// 1 => slave did not respond -// 2 => checksum error -int serial_update_buffers(int master_update) -{ - int status, smatstatus; - static int need_retry = 0; - - if( s_change_old != s_change_new ) { - smatstatus = soft_serial_transaction(GET_SLAVE_BUFFER); - if( smatstatus == TRANSACTION_END ) { - s_change_old = s_change_new; -#ifdef CONSOLE_ENABLE - uprintf("slave matrix = %b %b %b %b %b\n", - serial_slave_buffer[0], serial_slave_buffer[1], - serial_slave_buffer[2], serial_slave_buffer[3], - serial_slave_buffer[4] ); -#endif - } - } else { - // serial_slave_buffer dosen't change - smatstatus = TRANSACTION_END; // dummy status - } - - if( !master_update && !need_retry) { - status = soft_serial_transaction(GET_SLAVE_STATUS); - } else { - status = soft_serial_transaction(PUT_MASTER_GET_SLAVE_STATUS); - } - if( status == TRANSACTION_END ) { - s_change_new = slave_buffer_change_count; - need_retry = 0; - } else { - need_retry = 1; - } - return smatstatus; -} - -#endif // SERIAL_USE_MULTI_TRANSACTION -#endif /* USE_SERIAL */ diff --git a/keyboards/naked60/rev1/split_scomm.h b/keyboards/naked60/rev1/split_scomm.h deleted file mode 100644 index 537ec40808..0000000000 --- a/keyboards/naked60/rev1/split_scomm.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#ifndef SERIAL_USE_MULTI_TRANSACTION -/* --- USE Simple API (OLD API, compatible with let's split serial.c) --- */ -#include "serial.h" - -#else -/* --- USE flexible API (using multi-type transaction function) --- */ -// Buffers for master - slave communication -#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2 -#define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2 - -extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH]; -extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH]; -extern uint8_t slave_buffer_change_count; - -void serial_master_init(void); -void serial_slave_init(void); -int serial_update_buffers(int master_changed); - -#endif - diff --git a/keyboards/naked60/rev1/split_util.c b/keyboards/naked60/rev1/split_util.c deleted file mode 100644 index e1ff8b4379..0000000000 --- a/keyboards/naked60/rev1/split_util.c +++ /dev/null @@ -1,70 +0,0 @@ -#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(); -} diff --git a/keyboards/naked60/rev1/split_util.h b/keyboards/naked60/rev1/split_util.h deleted file mode 100644 index f593047560..0000000000 --- a/keyboards/naked60/rev1/split_util.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include <stdbool.h> -#include "eeconfig.h" - -#define SLAVE_I2C_ADDRESS 0x32 - -extern volatile bool isLeftHand; - -// slave version of matix scan, defined in matrix.c -void matrix_slave_scan(void); - -void split_keyboard_setup(void); -bool has_usb(void); - -void matrix_master_OLED_init (void); |