From 72d4e4bfd76b2c83b89787f8b3a8ba779a3e8d81 Mon Sep 17 00:00:00 2001 From: Takeshi ISHII <2170248+mtei@users.noreply.github.com> Date: Tue, 25 Dec 2018 04:14:57 +0900 Subject: Replace serial.c of quantum/split_common/ (#4669) * Add provisional Helix implementation to test the quantum/split_common. * copy keyboards/helix/serial.[ch] to quantum/split_common/ * Make serial.c a pure driver. Remove buffer name and buffer size from serial.c. They should be placed in the caller(matrix.c, split_utils.c). * remove quantum/split_common/serial_backward_compatibility.h * Changed array serial_master_buffer to structure serial_m2s_buffer. * Changed array serial_slave_buffer to structure serial_s2m_buffer. * Change keyboards/miniaxe/matrix.c I also made changes to quantum/split_comon/matrix.c to keyboards/miniaxe/matrix.c. Note: I contacted @ka2hiro, creator of miniaxe, and I got permission to change keyboards/miniaxe/matrix.c. * update history comment in quantum/split_common/serial.c * Revert "Add provisional Helix implementation to test the quantum/split_common." This reverts commit 168c82ef82c88e79979d9796bab9cc819cc2f685. * fix keyboards/miniaxe/matrix.c, quantum/split_common/matrix.c avr-gcc 4.9.[23] report error. avr-gcc 5.4.0, avr-gcc 7.3.0 pass. It is funny. * update comment quantum/split_common/serial.c * Reserve RGBLIGHT_SPLIT macro in quantum/split_common --- keyboards/miniaxe/matrix.c | 59 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 7 deletions(-) (limited to 'keyboards') diff --git a/keyboards/miniaxe/matrix.c b/keyboards/miniaxe/matrix.c index 55c458e1f..5fec1281d 100644 --- a/keyboards/miniaxe/matrix.c +++ b/keyboards/miniaxe/matrix.c @@ -32,9 +32,6 @@ along with this program. If not, see . #include "timer.h" #include "split_flags.h" -#ifdef RGBLIGHT_ENABLE -# include "rgblight.h" -#endif #ifdef BACKLIGHT_ENABLE # include "backlight.h" extern backlight_config_t backlight_config; @@ -55,6 +52,8 @@ along with this program. If not, see . static bool debouncing = false; #endif +#if defined(USE_I2C) || defined(EH) + #if (MATRIX_COLS <= 8) # define print_matrix_header() print("\nr/c 01234567\n") # define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) @@ -62,6 +61,27 @@ along with this program. If not, see . # define ROW_SHIFTER ((uint8_t)1) #else # error "Currently only supports 8 COLS" +#endif + +#else // USE_SERIAL + +#if (MATRIX_COLS <= 8) +# define print_matrix_header() print("\nr/c 01234567\n") +# define print_matrix_row(row) print_bin_reverse8(matrix_get_row(row)) +# define matrix_bitpop(i) bitpop(matrix[i]) +# define ROW_SHIFTER ((uint8_t)1) +#elif (MATRIX_COLS <= 16) +# define print_matrix_header() print("\nr/c 0123456789ABCDEF\n") +# define print_matrix_row(row) print_bin_reverse16(matrix_get_row(row)) +# define matrix_bitpop(i) bitpop16(matrix[i]) +# define ROW_SHIFTER ((uint16_t)1) +#elif (MATRIX_COLS <= 32) +# define print_matrix_header() print("\nr/c 0123456789ABCDEF0123456789ABCDEF\n") +# define print_matrix_row(row) print_bin_reverse32(matrix_get_row(row)) +# define matrix_bitpop(i) bitpop32(matrix[i]) +# define ROW_SHIFTER ((uint32_t)1) +#endif + #endif static matrix_row_t matrix_debouncing[MATRIX_ROWS]; @@ -315,15 +335,39 @@ i2c_error: // the cable is disconnceted, or something else went wrong #else // USE_SERIAL + +typedef struct _Serial_s2m_buffer_t { + // TODO: if MATRIX_COLS > 8 change to uint8_t packed_matrix[] for pack/unpack + matrix_row_t smatrix[ROWS_PER_HAND]; +} Serial_s2m_buffer_t; + +volatile Serial_s2m_buffer_t serial_s2m_buffer = {}; +volatile Serial_m2s_buffer_t serial_m2s_buffer = {}; +uint8_t volatile status0 = 0; + +SSTD_t transactions[] = { + { (uint8_t *)&status0, + sizeof(serial_m2s_buffer), (uint8_t *)&serial_m2s_buffer, + sizeof(serial_s2m_buffer), (uint8_t *)&serial_s2m_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)); } + int serial_transaction(void) { int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0; - if (serial_update_buffers()) { + if (soft_serial_transaction()) { return 1; } + // TODO: if MATRIX_COLS > 8 change to unpack() for (int i = 0; i < ROWS_PER_HAND; ++i) { - matrix[slaveOffset+i] = serial_slave_buffer[i]; + matrix[slaveOffset+i] = serial_s2m_buffer.smatrix[i]; } #ifdef RGBLIGHT_ENABLE @@ -332,7 +376,7 @@ int serial_transaction(void) { #ifdef BACKLIGHT_ENABLE // Write backlight level for slave to read - serial_master_buffer[SERIAL_BACKLIT_START] = backlight_config.enable ? backlight_config.level : 0; + serial_m2s_buffer.backlight_level = backlight_config.enable ? backlight_config.level : 0; #endif return 0; @@ -375,8 +419,9 @@ void matrix_slave_scan(void) { i2c_slave_buffer[I2C_KEYMAP_START+i] = matrix[offset+i]; } #else // USE_SERIAL + // TODO: if MATRIX_COLS > 8 change to pack() for (int i = 0; i < ROWS_PER_HAND; ++i) { - serial_slave_buffer[i] = matrix[offset+i]; + serial_s2m_buffer.smatrix[i] = matrix[offset+i]; } #endif matrix_slave_scan_user(); -- cgit v1.2.3-24-g4f1b