aboutsummaryrefslogtreecommitdiff
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)
downloadqmk_firmware-d1806a26e4ad75fa0e0405283803eba22c1a49ba.tar.gz
qmk_firmware-d1806a26e4ad75fa0e0405283803eba22c1a49ba.zip
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 bad762b49..d6636b886 100644
--- a/quantum/split_common/matrix.c
+++ b/quantum/split_common/matrix.c
@@ -257,7 +257,7 @@ bool matrix_post_scan(void) {
257 static uint8_t error_count; 257 static uint8_t error_count;
258 258
259 matrix_row_t slave_matrix[ROWS_PER_HAND] = {0}; 259 matrix_row_t slave_matrix[ROWS_PER_HAND] = {0};
260 if (!transport_master(slave_matrix)) { 260 if (!transport_master(matrix + thisHand, slave_matrix)) {
261 error_count++; 261 error_count++;
262 262
263 if (error_count > ERROR_DISCONNECT_COUNT) { 263 if (error_count > ERROR_DISCONNECT_COUNT) {
@@ -282,7 +282,7 @@ bool matrix_post_scan(void) {
282 282
283 matrix_scan_quantum(); 283 matrix_scan_quantum();
284 } else { 284 } else {
285 transport_slave(matrix + thisHand); 285 transport_slave(matrix + thatHand, matrix + thisHand);
286 286
287 matrix_slave_scan_user(); 287 matrix_slave_scan_user();
288 } 288 }
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c
index b45ba92c3..977b5dc33 100644
--- a/quantum/split_common/transport.c
+++ b/quantum/split_common/transport.c
@@ -31,6 +31,9 @@ typedef struct _I2C_slave_buffer_t {
31# ifndef DISABLE_SYNC_TIMER 31# ifndef DISABLE_SYNC_TIMER
32 uint32_t sync_timer; 32 uint32_t sync_timer;
33# endif 33# endif
34# ifdef SPLIT_TRANSPORT_MIRROR
35 matrix_row_t mmatrix[ROWS_PER_HAND];
36# endif
34 matrix_row_t smatrix[ROWS_PER_HAND]; 37 matrix_row_t smatrix[ROWS_PER_HAND];
35# ifdef SPLIT_MODS_ENABLE 38# ifdef SPLIT_MODS_ENABLE
36 uint8_t real_mods; 39 uint8_t real_mods;
@@ -56,7 +59,8 @@ typedef struct _I2C_slave_buffer_t {
56static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg; 59static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg;
57 60
58# define I2C_SYNC_TIME_START offsetof(I2C_slave_buffer_t, sync_timer) 61# define I2C_SYNC_TIME_START offsetof(I2C_slave_buffer_t, sync_timer)
59# define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, smatrix) 62# define I2C_KEYMAP_MASTER_START offsetof(I2C_slave_buffer_t, mmatrix)
63# define I2C_KEYMAP_SLAVE_START offsetof(I2C_slave_buffer_t, smatrix)
60# define I2C_REAL_MODS_START offsetof(I2C_slave_buffer_t, real_mods) 64# define I2C_REAL_MODS_START offsetof(I2C_slave_buffer_t, real_mods)
61# define I2C_WEAK_MODS_START offsetof(I2C_slave_buffer_t, weak_mods) 65# define I2C_WEAK_MODS_START offsetof(I2C_slave_buffer_t, weak_mods)
62# define I2C_ONESHOT_MODS_START offsetof(I2C_slave_buffer_t, oneshot_mods) 66# 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
72# endif 76# endif
73 77
74// Get rows from other half over i2c 78// Get rows from other half over i2c
75bool transport_master(matrix_row_t matrix[]) { 79bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
76 i2c_readReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_START, (void *)matrix, sizeof(i2c_buffer->smatrix), TIMEOUT); 80 i2c_readReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_SLAVE_START, (void *)slave_matrix, sizeof(i2c_buffer->smatrix), TIMEOUT);
81#ifdef SPLIT_TRANSPORT_MIRROR
82 i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_MASTER_START, (void *)master_matrix, sizeof(i2c_buffer->mmatrix), TIMEOUT);
83#endif
77 84
78 // write backlight info 85 // write backlight info
79# ifdef BACKLIGHT_ENABLE 86# ifdef BACKLIGHT_ENABLE
@@ -141,12 +148,15 @@ bool transport_master(matrix_row_t matrix[]) {
141 return true; 148 return true;
142} 149}
143 150
144void transport_slave(matrix_row_t matrix[]) { 151void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
145# ifndef DISABLE_SYNC_TIMER 152# ifndef DISABLE_SYNC_TIMER
146 sync_timer_update(i2c_buffer->sync_timer); 153 sync_timer_update(i2c_buffer->sync_timer);
147# endif 154# endif
148 // Copy matrix to I2C buffer 155 // Copy matrix to I2C buffer
149 memcpy((void *)i2c_buffer->smatrix, (void *)matrix, sizeof(i2c_buffer->smatrix)); 156 memcpy((void*)i2c_buffer->smatrix, (void *)slave_matrix, sizeof(i2c_buffer->smatrix));
157#ifdef SPLIT_TRANSPORT_MIRROR
158 memcpy((void*)master_matrix, (void *)i2c_buffer->mmatrix, sizeof(i2c_buffer->mmatrix));
159#endif
150 160
151// Read Backlight Info 161// Read Backlight Info
152# ifdef BACKLIGHT_ENABLE 162# ifdef BACKLIGHT_ENABLE
@@ -207,6 +217,9 @@ typedef struct _Serial_m2s_buffer_t {
207# ifndef DISABLE_SYNC_TIMER 217# ifndef DISABLE_SYNC_TIMER
208 uint32_t sync_timer; 218 uint32_t sync_timer;
209# endif 219# endif
220# ifdef SPLIT_TRANSPORT_MIRROR
221 matrix_row_t mmatrix[ROWS_PER_HAND];
222# endif
210# ifdef BACKLIGHT_ENABLE 223# ifdef BACKLIGHT_ENABLE
211 uint8_t backlight_level; 224 uint8_t backlight_level;
212# endif 225# endif
@@ -289,7 +302,7 @@ void transport_rgblight_slave(void) {
289# define transport_rgblight_slave() 302# define transport_rgblight_slave()
290# endif 303# endif
291 304
292bool transport_master(matrix_row_t matrix[]) { 305bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
293# ifndef SERIAL_USE_MULTI_TRANSACTION 306# ifndef SERIAL_USE_MULTI_TRANSACTION
294 if (soft_serial_transaction() != TRANSACTION_END) { 307 if (soft_serial_transaction() != TRANSACTION_END) {
295 return false; 308 return false;
@@ -303,7 +316,10 @@ bool transport_master(matrix_row_t matrix[]) {
303 316
304 // TODO: if MATRIX_COLS > 8 change to unpack() 317 // TODO: if MATRIX_COLS > 8 change to unpack()
305 for (int i = 0; i < ROWS_PER_HAND; ++i) { 318 for (int i = 0; i < ROWS_PER_HAND; ++i) {
306 matrix[i] = serial_s2m_buffer.smatrix[i]; 319 slave_matrix[i] = serial_s2m_buffer.smatrix[i];
320#ifdef SPLIT_TRANSPORT_MIRROR
321 serial_m2s_buffer.mmatrix[i] = master_matrix[i];
322#endif
307 } 323 }
308 324
309# ifdef BACKLIGHT_ENABLE 325# ifdef BACKLIGHT_ENABLE
@@ -333,7 +349,7 @@ bool transport_master(matrix_row_t matrix[]) {
333 return true; 349 return true;
334} 350}
335 351
336void transport_slave(matrix_row_t matrix[]) { 352void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
337 transport_rgblight_slave(); 353 transport_rgblight_slave();
338# ifndef DISABLE_SYNC_TIMER 354# ifndef DISABLE_SYNC_TIMER
339 sync_timer_update(serial_m2s_buffer.sync_timer); 355 sync_timer_update(serial_m2s_buffer.sync_timer);
@@ -341,7 +357,10 @@ void transport_slave(matrix_row_t matrix[]) {
341 357
342 // TODO: if MATRIX_COLS > 8 change to pack() 358 // TODO: if MATRIX_COLS > 8 change to pack()
343 for (int i = 0; i < ROWS_PER_HAND; ++i) { 359 for (int i = 0; i < ROWS_PER_HAND; ++i) {
344 serial_s2m_buffer.smatrix[i] = matrix[i]; 360 serial_s2m_buffer.smatrix[i] = slave_matrix[i];
361#ifdef SPLIT_TRANSPORT_MIRROR
362 master_matrix[i] = serial_m2s_buffer.mmatrix[i];
363#endif
345 } 364 }
346# ifdef BACKLIGHT_ENABLE 365# ifdef BACKLIGHT_ENABLE
347 backlight_set(serial_m2s_buffer.backlight_level); 366 backlight_set(serial_m2s_buffer.backlight_level);
diff --git a/quantum/split_common/transport.h b/quantum/split_common/transport.h
index c667bfab8..a9f66301b 100644
--- a/quantum/split_common/transport.h
+++ b/quantum/split_common/transport.h
@@ -6,5 +6,5 @@ void transport_master_init(void);
6void transport_slave_init(void); 6void transport_slave_init(void);
7 7
8// returns false if valid data not received from slave 8// returns false if valid data not received from slave
9bool transport_master(matrix_row_t matrix[]); 9bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]);
10void transport_slave(matrix_row_t matrix[]); 10void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]);