diff options
Diffstat (limited to 'quantum/split_common/transport.c')
| -rw-r--r-- | quantum/split_common/transport.c | 37 |
1 files changed, 28 insertions, 9 deletions
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 { | |||
| 56 | static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg; | 59 | static 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 |
| 75 | bool transport_master(matrix_row_t matrix[]) { | 79 | bool 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 | ||
| 144 | void transport_slave(matrix_row_t matrix[]) { | 151 | void 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 | ||
| 292 | bool transport_master(matrix_row_t matrix[]) { | 305 | bool 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 | ||
| 336 | void transport_slave(matrix_row_t matrix[]) { | 352 | void 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); |
