summaryrefslogtreecommitdiff
path: root/quantum/split_common
diff options
context:
space:
mode:
authorXScorpion2 <rcalt2vt@gmail.com>2021-02-15 18:30:33 -0600
committerGitHub <noreply@github.com>2021-02-16 11:30:33 +1100
commitd1806a26e4ad75fa0e0405283803eba22c1a49ba (patch)
tree25bf2750e9770781cff373114bd44736463a91f1 /quantum/split_common
parent1bc8a6e5d49861b268f9274a8686a2640e36e0b5 (diff)
Split transport mirror (#11046)
* Split transport mirror support * Updated RGB Matrix to respond to electrical events instead of key events * split matrix slave fix
Diffstat (limited to 'quantum/split_common')
-rw-r--r--quantum/split_common/matrix.c4
-rw-r--r--quantum/split_common/transport.c37
-rw-r--r--quantum/split_common/transport.h4
3 files changed, 32 insertions, 13 deletions
diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c
index bad762b493..d6636b886a 100644
--- a/quantum/split_common/matrix.c
+++ b/quantum/split_common/matrix.c
@@ -257,7 +257,7 @@ bool matrix_post_scan(void) {
static uint8_t error_count;
matrix_row_t slave_matrix[ROWS_PER_HAND] = {0};
- if (!transport_master(slave_matrix)) {
+ if (!transport_master(matrix + thisHand, slave_matrix)) {
error_count++;
if (error_count > ERROR_DISCONNECT_COUNT) {
@@ -282,7 +282,7 @@ bool matrix_post_scan(void) {
matrix_scan_quantum();
} else {
- transport_slave(matrix + thisHand);
+ transport_slave(matrix + thatHand, matrix + thisHand);
matrix_slave_scan_user();
}
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c
index b45ba92c3b..977b5dc33e 100644
--- a/quantum/split_common/transport.c
+++ b/quantum/split_common/transport.c
@@ -31,6 +31,9 @@ typedef struct _I2C_slave_buffer_t {
# ifndef DISABLE_SYNC_TIMER
uint32_t sync_timer;
# endif
+# ifdef SPLIT_TRANSPORT_MIRROR
+ matrix_row_t mmatrix[ROWS_PER_HAND];
+# endif
matrix_row_t smatrix[ROWS_PER_HAND];
# ifdef SPLIT_MODS_ENABLE
uint8_t real_mods;
@@ -56,7 +59,8 @@ typedef struct _I2C_slave_buffer_t {
static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg;
# define I2C_SYNC_TIME_START offsetof(I2C_slave_buffer_t, sync_timer)
-# define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, smatrix)
+# define I2C_KEYMAP_MASTER_START offsetof(I2C_slave_buffer_t, mmatrix)
+# define I2C_KEYMAP_SLAVE_START offsetof(I2C_slave_buffer_t, smatrix)
# define I2C_REAL_MODS_START offsetof(I2C_slave_buffer_t, real_mods)
# define I2C_WEAK_MODS_START offsetof(I2C_slave_buffer_t, weak_mods)
# define I2C_ONESHOT_MODS_START offsetof(I2C_slave_buffer_t, oneshot_mods)
@@ -72,8 +76,11 @@ static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_re
# endif
// Get rows from other half over i2c
-bool transport_master(matrix_row_t matrix[]) {
- i2c_readReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_START, (void *)matrix, sizeof(i2c_buffer->smatrix), TIMEOUT);
+bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
+ i2c_readReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_SLAVE_START, (void *)slave_matrix, sizeof(i2c_buffer->smatrix), TIMEOUT);
+#ifdef SPLIT_TRANSPORT_MIRROR
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_MASTER_START, (void *)master_matrix, sizeof(i2c_buffer->mmatrix), TIMEOUT);
+#endif
// write backlight info
# ifdef BACKLIGHT_ENABLE
@@ -141,12 +148,15 @@ bool transport_master(matrix_row_t matrix[]) {
return true;
}
-void transport_slave(matrix_row_t matrix[]) {
+void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
# ifndef DISABLE_SYNC_TIMER
sync_timer_update(i2c_buffer->sync_timer);
# endif
// Copy matrix to I2C buffer
- memcpy((void *)i2c_buffer->smatrix, (void *)matrix, sizeof(i2c_buffer->smatrix));
+ memcpy((void*)i2c_buffer->smatrix, (void *)slave_matrix, sizeof(i2c_buffer->smatrix));
+#ifdef SPLIT_TRANSPORT_MIRROR
+ memcpy((void*)master_matrix, (void *)i2c_buffer->mmatrix, sizeof(i2c_buffer->mmatrix));
+#endif
// Read Backlight Info
# ifdef BACKLIGHT_ENABLE
@@ -207,6 +217,9 @@ typedef struct _Serial_m2s_buffer_t {
# ifndef DISABLE_SYNC_TIMER
uint32_t sync_timer;
# endif
+# ifdef SPLIT_TRANSPORT_MIRROR
+ matrix_row_t mmatrix[ROWS_PER_HAND];
+# endif
# ifdef BACKLIGHT_ENABLE
uint8_t backlight_level;
# endif
@@ -289,7 +302,7 @@ void transport_rgblight_slave(void) {
# define transport_rgblight_slave()
# endif
-bool transport_master(matrix_row_t matrix[]) {
+bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
# ifndef SERIAL_USE_MULTI_TRANSACTION
if (soft_serial_transaction() != TRANSACTION_END) {
return false;
@@ -303,7 +316,10 @@ bool transport_master(matrix_row_t matrix[]) {
// TODO: if MATRIX_COLS > 8 change to unpack()
for (int i = 0; i < ROWS_PER_HAND; ++i) {
- matrix[i] = serial_s2m_buffer.smatrix[i];
+ slave_matrix[i] = serial_s2m_buffer.smatrix[i];
+#ifdef SPLIT_TRANSPORT_MIRROR
+ serial_m2s_buffer.mmatrix[i] = master_matrix[i];
+#endif
}
# ifdef BACKLIGHT_ENABLE
@@ -333,7 +349,7 @@ bool transport_master(matrix_row_t matrix[]) {
return true;
}
-void transport_slave(matrix_row_t matrix[]) {
+void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
transport_rgblight_slave();
# ifndef DISABLE_SYNC_TIMER
sync_timer_update(serial_m2s_buffer.sync_timer);
@@ -341,7 +357,10 @@ void transport_slave(matrix_row_t matrix[]) {
// TODO: if MATRIX_COLS > 8 change to pack()
for (int i = 0; i < ROWS_PER_HAND; ++i) {
- serial_s2m_buffer.smatrix[i] = matrix[i];
+ serial_s2m_buffer.smatrix[i] = slave_matrix[i];
+#ifdef SPLIT_TRANSPORT_MIRROR
+ master_matrix[i] = serial_m2s_buffer.mmatrix[i];
+#endif
}
# ifdef BACKLIGHT_ENABLE
backlight_set(serial_m2s_buffer.backlight_level);
diff --git a/quantum/split_common/transport.h b/quantum/split_common/transport.h
index c667bfab85..a9f66301bf 100644
--- a/quantum/split_common/transport.h
+++ b/quantum/split_common/transport.h
@@ -6,5 +6,5 @@ void transport_master_init(void);
void transport_slave_init(void);
// returns false if valid data not received from slave
-bool transport_master(matrix_row_t matrix[]);
-void transport_slave(matrix_row_t matrix[]);
+bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]);
+void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]);