diff options
Diffstat (limited to 'quantum/split_common/transport.c')
| -rw-r--r-- | quantum/split_common/transport.c | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c index 61b61ea08..27a1c0d3a 100644 --- a/quantum/split_common/transport.c +++ b/quantum/split_common/transport.c | |||
| @@ -22,6 +22,10 @@ static pin_t encoders_pad[] = ENCODERS_PAD_A; | |||
| 22 | # define NUMBER_OF_ENCODERS (sizeof(encoders_pad) / sizeof(pin_t)) | 22 | # define NUMBER_OF_ENCODERS (sizeof(encoders_pad) / sizeof(pin_t)) |
| 23 | #endif | 23 | #endif |
| 24 | 24 | ||
| 25 | #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 26 | # include "rgb_matrix.h" | ||
| 27 | #endif | ||
| 28 | |||
| 25 | #if defined(USE_I2C) | 29 | #if defined(USE_I2C) |
| 26 | 30 | ||
| 27 | # include "i2c_master.h" | 31 | # include "i2c_master.h" |
| @@ -54,6 +58,10 @@ typedef struct _I2C_slave_buffer_t { | |||
| 54 | # ifdef WPM_ENABLE | 58 | # ifdef WPM_ENABLE |
| 55 | uint8_t current_wpm; | 59 | uint8_t current_wpm; |
| 56 | # endif | 60 | # endif |
| 61 | # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 62 | rgb_config_t rgb_matrix; | ||
| 63 | bool rgb_suspend_state; | ||
| 64 | # endif | ||
| 57 | } I2C_slave_buffer_t; | 65 | } I2C_slave_buffer_t; |
| 58 | 66 | ||
| 59 | static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg; | 67 | static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg; |
| @@ -68,6 +76,8 @@ static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_re | |||
| 68 | # define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync) | 76 | # define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync) |
| 69 | # define I2C_ENCODER_START offsetof(I2C_slave_buffer_t, encoder_state) | 77 | # define I2C_ENCODER_START offsetof(I2C_slave_buffer_t, encoder_state) |
| 70 | # define I2C_WPM_START offsetof(I2C_slave_buffer_t, current_wpm) | 78 | # define I2C_WPM_START offsetof(I2C_slave_buffer_t, current_wpm) |
| 79 | # define I2C_RGB_MATRIX_START offsetof(I2C_slave_buffer_t, rgb_matrix) | ||
| 80 | # define I2C_RGB_SUSPEND_START offsetof(I2C_slave_buffer_t, rgb_suspend_state) | ||
| 71 | 81 | ||
| 72 | # define TIMEOUT 100 | 82 | # define TIMEOUT 100 |
| 73 | 83 | ||
| @@ -141,6 +151,11 @@ bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) | |||
| 141 | # endif | 151 | # endif |
| 142 | # endif | 152 | # endif |
| 143 | 153 | ||
| 154 | # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 155 | i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_MATRIX_START, (void *)rgb_matrix_config, sizeof(i2c_buffer->rgb_matrix), TIMEOUT); | ||
| 156 | i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_SUSPEND_START, (void *)g_suspend_state, sizeof(i2c_buffer->rgb_suspend_state), TIMEOUT); | ||
| 157 | # endif | ||
| 158 | |||
| 144 | # ifndef DISABLE_SYNC_TIMER | 159 | # ifndef DISABLE_SYNC_TIMER |
| 145 | i2c_buffer->sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET; | 160 | i2c_buffer->sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET; |
| 146 | i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_SYNC_TIME_START, (void *)&i2c_buffer->sync_timer, sizeof(i2c_buffer->sync_timer), TIMEOUT); | 161 | i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_SYNC_TIME_START, (void *)&i2c_buffer->sync_timer, sizeof(i2c_buffer->sync_timer), TIMEOUT); |
| @@ -186,6 +201,11 @@ void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) | |||
| 186 | set_oneshot_mods(i2c_buffer->oneshot_mods); | 201 | set_oneshot_mods(i2c_buffer->oneshot_mods); |
| 187 | # endif | 202 | # endif |
| 188 | # endif | 203 | # endif |
| 204 | |||
| 205 | # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 206 | memcpy((void *)i2c_buffer->rgb_matrix, (void *)rgb_matrix_config, sizeof(i2c_buffer->rgb_matrix)); | ||
| 207 | memcpy((void *)i2c_buffer->rgb_suspend_state, (void *)g_suspend_state, sizeof(i2c_buffer->rgb_suspend_state)); | ||
| 208 | # endif | ||
| 189 | } | 209 | } |
| 190 | 210 | ||
| 191 | void transport_master_init(void) { i2c_init(); } | 211 | void transport_master_init(void) { i2c_init(); } |
| @@ -226,6 +246,10 @@ typedef struct _Serial_m2s_buffer_t { | |||
| 226 | # ifdef WPM_ENABLE | 246 | # ifdef WPM_ENABLE |
| 227 | uint8_t current_wpm; | 247 | uint8_t current_wpm; |
| 228 | # endif | 248 | # endif |
| 249 | # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 250 | rgb_config_t rgb_matrix; | ||
| 251 | bool rgb_suspend_state; | ||
| 252 | # endif | ||
| 229 | } Serial_m2s_buffer_t; | 253 | } Serial_m2s_buffer_t; |
| 230 | 254 | ||
| 231 | # if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | 255 | # if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) |
| @@ -333,18 +357,24 @@ bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) | |||
| 333 | 357 | ||
| 334 | # ifdef WPM_ENABLE | 358 | # ifdef WPM_ENABLE |
| 335 | // Write wpm to slave | 359 | // Write wpm to slave |
| 336 | serial_m2s_buffer.current_wpm = get_current_wpm(); | 360 | serial_m2s_buffer.current_wpm = get_current_wpm(); |
| 337 | # endif | 361 | # endif |
| 338 | 362 | ||
| 339 | # ifdef SPLIT_MODS_ENABLE | 363 | # ifdef SPLIT_MODS_ENABLE |
| 340 | serial_m2s_buffer.real_mods = get_mods(); | 364 | serial_m2s_buffer.real_mods = get_mods(); |
| 341 | serial_m2s_buffer.weak_mods = get_weak_mods(); | 365 | serial_m2s_buffer.weak_mods = get_weak_mods(); |
| 342 | # ifndef NO_ACTION_ONESHOT | 366 | # ifndef NO_ACTION_ONESHOT |
| 343 | serial_m2s_buffer.oneshot_mods = get_oneshot_mods(); | 367 | serial_m2s_buffer.oneshot_mods = get_oneshot_mods(); |
| 344 | # endif | 368 | # endif |
| 345 | # endif | 369 | # endif |
| 370 | |||
| 371 | # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 372 | serial_m2s_buffer.rgb_matrix = rgb_matrix_config; | ||
| 373 | serial_m2s_buffer.rgb_suspend_state = g_suspend_state; | ||
| 374 | # endif | ||
| 375 | |||
| 346 | # ifndef DISABLE_SYNC_TIMER | 376 | # ifndef DISABLE_SYNC_TIMER |
| 347 | serial_m2s_buffer.sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET; | 377 | serial_m2s_buffer.sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET; |
| 348 | # endif | 378 | # endif |
| 349 | return true; | 379 | return true; |
| 350 | } | 380 | } |
| @@ -381,6 +411,11 @@ void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) | |||
| 381 | set_oneshot_mods(serial_m2s_buffer.oneshot_mods); | 411 | set_oneshot_mods(serial_m2s_buffer.oneshot_mods); |
| 382 | # endif | 412 | # endif |
| 383 | # endif | 413 | # endif |
| 414 | |||
| 415 | # if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) | ||
| 416 | rgb_matrix_config = serial_m2s_buffer.rgb_matrix; | ||
| 417 | g_suspend_state = serial_m2s_buffer.rgb_suspend_state; | ||
| 418 | # endif | ||
| 384 | } | 419 | } |
| 385 | 420 | ||
| 386 | #endif | 421 | #endif |
