summaryrefslogtreecommitdiff
path: root/quantum/split_common/transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/split_common/transport.c')
-rw-r--r--quantum/split_common/transport.c90
1 files changed, 78 insertions, 12 deletions
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c
index 61b61ea08c..bf942c5260 100644
--- a/quantum/split_common/transport.c
+++ b/quantum/split_common/transport.c
@@ -22,6 +22,13 @@ static pin_t encoders_pad[] = ENCODERS_PAD_A;
# define NUMBER_OF_ENCODERS (sizeof(encoders_pad) / sizeof(pin_t))
#endif
+#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+# include "led_matrix.h"
+#endif
+#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+# include "rgb_matrix.h"
+#endif
+
#if defined(USE_I2C)
# include "i2c_master.h"
@@ -54,6 +61,14 @@ typedef struct _I2C_slave_buffer_t {
# ifdef WPM_ENABLE
uint8_t current_wpm;
# endif
+# if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ led_eeconfig_t led_matrix;
+ bool led_suspend_state;
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ rgb_config_t rgb_matrix;
+ bool rgb_suspend_state;
+# endif
} I2C_slave_buffer_t;
static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg;
@@ -68,6 +83,10 @@ static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_re
# define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync)
# define I2C_ENCODER_START offsetof(I2C_slave_buffer_t, encoder_state)
# define I2C_WPM_START offsetof(I2C_slave_buffer_t, current_wpm)
+# define I2C_LED_MATRIX_START offsetof(I2C_slave_buffer_t, led_matrix)
+# define I2C_LED_SUSPEND_START offsetof(I2C_slave_buffer_t, led_suspend_state)
+# define I2C_RGB_MATRIX_START offsetof(I2C_slave_buffer_t, rgb_matrix)
+# define I2C_RGB_SUSPEND_START offsetof(I2C_slave_buffer_t, rgb_suspend_state)
# define TIMEOUT 100
@@ -141,6 +160,17 @@ bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[])
# endif
# endif
+# if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_LED_MATRIX_START, (void *)led_matrix_eeconfig, sizeof(i2c_buffer->led_matrix), TIMEOUT);
+ bool suspend_state = led_matrix_get_suspend_state();
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_LED_SUSPEND_START, (void *)suspend_state, sizeof(i2c_buffer->led_suspend_state), TIMEOUT);
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_MATRIX_START, (void *)rgb_matrix_config, sizeof(i2c_buffer->rgb_matrix), TIMEOUT);
+ bool suspend_state = rgb_matrix_get_suspend_state();
+ i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_SUSPEND_START, (void *)suspend_state, sizeof(i2c_buffer->rgb_suspend_state), TIMEOUT);
+# endif
+
# ifndef DISABLE_SYNC_TIMER
i2c_buffer->sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET;
i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_SYNC_TIME_START, (void *)&i2c_buffer->sync_timer, sizeof(i2c_buffer->sync_timer), TIMEOUT);
@@ -186,6 +216,15 @@ void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[])
set_oneshot_mods(i2c_buffer->oneshot_mods);
# endif
# endif
+
+# if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ memcpy((void *)i2c_buffer->led_matrix, (void *)led_matrix_eeconfig, sizeof(i2c_buffer->led_matrix));
+ led_matrix_set_suspend_state(i2c_buffer->led_suspend_state);
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ memcpy((void *)i2c_buffer->rgb_matrix, (void *)rgb_matrix_config, sizeof(i2c_buffer->rgb_matrix));
+ rgb_matrix_set_suspend_state(i2c_buffer->rgb_suspend_state);
+# endif
}
void transport_master_init(void) { i2c_init(); }
@@ -208,23 +247,31 @@ typedef struct _Serial_s2m_buffer_t {
typedef struct _Serial_m2s_buffer_t {
# ifdef SPLIT_MODS_ENABLE
- uint8_t real_mods;
- uint8_t weak_mods;
+ uint8_t real_mods;
+ uint8_t weak_mods;
# ifndef NO_ACTION_ONESHOT
- uint8_t oneshot_mods;
+ uint8_t oneshot_mods;
# endif
# endif
# ifndef DISABLE_SYNC_TIMER
- uint32_t sync_timer;
+ uint32_t sync_timer;
# endif
# ifdef SPLIT_TRANSPORT_MIRROR
- matrix_row_t mmatrix[ROWS_PER_HAND];
+ matrix_row_t mmatrix[ROWS_PER_HAND];
# endif
# ifdef BACKLIGHT_ENABLE
- uint8_t backlight_level;
+ uint8_t backlight_level;
# endif
# ifdef WPM_ENABLE
- uint8_t current_wpm;
+ uint8_t current_wpm;
+# endif
+# if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ led_eeconfig_t led_matrix;
+ bool led_suspend_state;
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ rgb_config_t rgb_matrix;
+ bool rgb_suspend_state;
# endif
} Serial_m2s_buffer_t;
@@ -333,18 +380,28 @@ bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[])
# ifdef WPM_ENABLE
// Write wpm to slave
- serial_m2s_buffer.current_wpm = get_current_wpm();
+ serial_m2s_buffer.current_wpm = get_current_wpm();
# endif
# ifdef SPLIT_MODS_ENABLE
- serial_m2s_buffer.real_mods = get_mods();
- serial_m2s_buffer.weak_mods = get_weak_mods();
+ serial_m2s_buffer.real_mods = get_mods();
+ serial_m2s_buffer.weak_mods = get_weak_mods();
# ifndef NO_ACTION_ONESHOT
- serial_m2s_buffer.oneshot_mods = get_oneshot_mods();
+ serial_m2s_buffer.oneshot_mods = get_oneshot_mods();
# endif
# endif
+
+# if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ serial_m2s_buffer.led_matrix = led_matrix_eeconfig;
+ serial_m2s_buffer.led_suspend_state = led_matrix_get_suspend_state();
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ serial_m2s_buffer.rgb_matrix = rgb_matrix_config;
+ serial_m2s_buffer.rgb_suspend_state = rgb_matrix_get_suspend_state();
+# endif
+
# ifndef DISABLE_SYNC_TIMER
- serial_m2s_buffer.sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET;
+ serial_m2s_buffer.sync_timer = sync_timer_read32() + SYNC_TIMER_OFFSET;
# endif
return true;
}
@@ -381,6 +438,15 @@ void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[])
set_oneshot_mods(serial_m2s_buffer.oneshot_mods);
# endif
# endif
+
+# if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
+ led_matrix_eeconfig = serial_m2s_buffer.led_matrix;
+ led_matrix_set_suspend_state(serial_m2s_buffer.led_suspend_state);
+# endif
+# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
+ rgb_matrix_config = serial_m2s_buffer.rgb_matrix;
+ rgb_matrix_set_suspend_state(serial_m2s_buffer.rgb_suspend_state);
+# endif
}
#endif