summaryrefslogtreecommitdiff
path: root/keyboards/yosino58/rev1
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/yosino58/rev1')
-rw-r--r--keyboards/yosino58/rev1/.noci0
-rw-r--r--keyboards/yosino58/rev1/config.h8
-rw-r--r--keyboards/yosino58/rev1/matrix.c343
-rw-r--r--keyboards/yosino58/rev1/rev1.h15
-rw-r--r--keyboards/yosino58/rev1/rules.mk23
-rw-r--r--keyboards/yosino58/rev1/serial_config.h4
-rw-r--r--keyboards/yosino58/rev1/serial_config_simpleapi.h5
-rw-r--r--keyboards/yosino58/rev1/split_scomm.c91
-rw-r--r--keyboards/yosino58/rev1/split_scomm.h21
-rw-r--r--keyboards/yosino58/rev1/split_util.c70
-rw-r--r--keyboards/yosino58/rev1/split_util.h16
11 files changed, 28 insertions, 568 deletions
diff --git a/keyboards/yosino58/rev1/.noci b/keyboards/yosino58/rev1/.noci
deleted file mode 100644
index e69de29bb2..0000000000
--- a/keyboards/yosino58/rev1/.noci
+++ /dev/null
diff --git a/keyboards/yosino58/rev1/config.h b/keyboards/yosino58/rev1/config.h
index 1ff856c8d8..13f69f18c9 100644
--- a/keyboards/yosino58/rev1/config.h
+++ b/keyboards/yosino58/rev1/config.h
@@ -18,6 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
+#include "config_common.h"
+
/* key matrix size */
// Rows are doubled-up
#define MATRIX_ROWS 10
@@ -26,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// wiring of each half
#define MATRIX_ROW_PINS { D4, C6, D7, E6, B4 }
#define MATRIX_COL_PINS { F4, F5, F6, F7, B1, B3 }
+#define DIODE_DIRECTION COL2ROW
/* define if matrix has ghost */
//#define MATRIX_HAS_GHOST
@@ -36,6 +39,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Set 0 if debouncing isn't needed */
#define DEBOUNCE 5
+/*
+ * Split Keyboard specific options, make sure you have 'SPLIT_KEYBOARD = yes' in your rules.mk, and define SOFT_SERIAL_PIN.
+ */
+#define SOFT_SERIAL_PIN D2 // or D1, D2, D3, E6
+
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
//#define LOCKING_SUPPORT_ENABLE
/* Locking resynchronize hack */
diff --git a/keyboards/yosino58/rev1/matrix.c b/keyboards/yosino58/rev1/matrix.c
deleted file mode 100644
index 802ce00cc6..0000000000
--- a/keyboards/yosino58/rev1/matrix.c
+++ /dev/null
@@ -1,343 +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 "quantum.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();
-
- setPinOutput(B0);
- setPinOutput(D5);
- writePinHigh(D5);
- writePinHigh(B0);
-
- // 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) writePinLow(B0);
- return 1;
- }
- writePinHigh(B0);
- memcpy(&matrix[slaveOffset],
- (void *)serial_slave_buffer, SERIAL_SLAVE_BUFFER_LENGTH);
- 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, SERIAL_MASTER_BUFFER_LENGTH);
- 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], SERIAL_MASTER_BUFFER_LENGTH);
- #endif
- memcpy((void *)serial_master_buffer,
- &matrix[offset], SERIAL_MASTER_BUFFER_LENGTH);
-#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
- writePinLow(D5);
-
- 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
- writePinHigh(D5);
- 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
-}
-
-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++) {
- print_hex8(row); print(": ");
- print_bin_reverse16(matrix_get_row(row));
- print("\n");
- }
-}
-
-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/yosino58/rev1/rev1.h b/keyboards/yosino58/rev1/rev1.h
index bc68892e88..c643c9d729 100644
--- a/keyboards/yosino58/rev1/rev1.h
+++ b/keyboards/yosino58/rev1/rev1.h
@@ -1,22 +1,7 @@
#pragma once
-#include "../yosino58.h"
-
#include "quantum.h"
-#ifdef RGBLIGHT_ENABLE
-//rgb led driver
-#include "ws2812.h"
-#endif
-
-#ifdef USE_I2C
-#include <stddef.h>
-#ifdef __AVR__
- #include <avr/io.h>
- #include <avr/interrupt.h>
-#endif
-#endif
-
#define LAYOUT( \
L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \
L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \
diff --git a/keyboards/yosino58/rev1/rules.mk b/keyboards/yosino58/rev1/rules.mk
index 6028b5a5b9..cf39e83a4f 100644
--- a/keyboards/yosino58/rev1/rules.mk
+++ b/keyboards/yosino58/rev1/rules.mk
@@ -1,3 +1,20 @@
-SRC += rev1/matrix.c
-SRC += rev1/split_util.c
-SRC += rev1/split_scomm.c
+# MCU name
+MCU = atmega32u4
+
+# Bootloader selection
+BOOTLOADER = caterina
+
+# Build Options
+# change yes to no to disable
+#
+BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite
+MOUSEKEY_ENABLE = no # Mouse keys
+EXTRAKEY_ENABLE = no # Audio control and System control
+CONSOLE_ENABLE = no # Console for debug
+COMMAND_ENABLE = no # Commands for debug and configuration
+NKRO_ENABLE = no # Enable N-Key Rollover
+BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
+AUDIO_ENABLE = no # Audio output
+RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
+SPLIT_KEYBOARD = yes
+OLED_DRIVER = SSD1306
diff --git a/keyboards/yosino58/rev1/serial_config.h b/keyboards/yosino58/rev1/serial_config.h
deleted file mode 100644
index 4fab8e8ddf..0000000000
--- a/keyboards/yosino58/rev1/serial_config.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef SOFT_SERIAL_PIN
-#define SOFT_SERIAL_PIN D2
-#define SERIAL_USE_MULTI_TRANSACTION
-#endif
diff --git a/keyboards/yosino58/rev1/serial_config_simpleapi.h b/keyboards/yosino58/rev1/serial_config_simpleapi.h
deleted file mode 100644
index 0e1dd9e4ac..0000000000
--- a/keyboards/yosino58/rev1/serial_config_simpleapi.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#pragma once
-
-#undef SERIAL_USE_MULTI_TRANSACTION
-#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
-#define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2
diff --git a/keyboards/yosino58/rev1/split_scomm.c b/keyboards/yosino58/rev1/split_scomm.c
deleted file mode 100644
index 82b53d7e7f..0000000000
--- a/keyboards/yosino58/rev1/split_scomm.c
+++ /dev/null
@@ -1,91 +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\n",
- serial_slave_buffer[0], serial_slave_buffer[1],
- serial_slave_buffer[2], serial_slave_buffer[3]);
-#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/yosino58/rev1/split_scomm.h b/keyboards/yosino58/rev1/split_scomm.h
deleted file mode 100644
index 16887eb74f..0000000000
--- a/keyboards/yosino58/rev1/split_scomm.h
+++ /dev/null
@@ -1,21 +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/yosino58/rev1/split_util.c b/keyboards/yosino58/rev1/split_util.c
deleted file mode 100644
index e1ff8b4379..0000000000
--- a/keyboards/yosino58/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/yosino58/rev1/split_util.h b/keyboards/yosino58/rev1/split_util.h
deleted file mode 100644
index f593047560..0000000000
--- a/keyboards/yosino58/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);