diff options
Diffstat (limited to 'quantum/split_common/transport.c')
| -rw-r--r-- | quantum/split_common/transport.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c index ab421adc4..3234a3ef5 100644 --- a/quantum/split_common/transport.c +++ b/quantum/split_common/transport.c | |||
| @@ -35,6 +35,9 @@ typedef struct _I2C_slave_buffer_t { | |||
| 35 | # ifdef ENCODER_ENABLE | 35 | # ifdef ENCODER_ENABLE |
| 36 | uint8_t encoder_state[NUMBER_OF_ENCODERS]; | 36 | uint8_t encoder_state[NUMBER_OF_ENCODERS]; |
| 37 | # endif | 37 | # endif |
| 38 | # ifdef WPM_ENABLE | ||
| 39 | uint8_t current_wpm; | ||
| 40 | # endif | ||
| 38 | } I2C_slave_buffer_t; | 41 | } I2C_slave_buffer_t; |
| 39 | 42 | ||
| 40 | static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg; | 43 | static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg; |
| @@ -43,6 +46,7 @@ static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_re | |||
| 43 | # define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync) | 46 | # define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync) |
| 44 | # define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, smatrix) | 47 | # define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, smatrix) |
| 45 | # define I2C_ENCODER_START offsetof(I2C_slave_buffer_t, encoder_state) | 48 | # define I2C_ENCODER_START offsetof(I2C_slave_buffer_t, encoder_state) |
| 49 | # define I2C_WPM_START offsetof(I2C_slave_buffer_t, current_wpm) | ||
| 46 | 50 | ||
| 47 | # define TIMEOUT 100 | 51 | # define TIMEOUT 100 |
| 48 | 52 | ||
| @@ -79,6 +83,14 @@ bool transport_master(matrix_row_t matrix[]) { | |||
| 79 | encoder_update_raw(i2c_buffer->encoder_state); | 83 | encoder_update_raw(i2c_buffer->encoder_state); |
| 80 | # endif | 84 | # endif |
| 81 | 85 | ||
| 86 | # ifdef WPM_ENABLE | ||
| 87 | uint8_t current_wpm = get_current_wpm(); | ||
| 88 | if(current_wpm != i2c_buffer->current_wpm) { | ||
| 89 | if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_WPM_START, (void *)¤t_wpm, sizeof(current_wpm), TIMEOUT) >= 0) { | ||
| 90 | i2c_buffer->current_wpm = current_wpm; | ||
| 91 | } | ||
| 92 | } | ||
| 93 | # endif | ||
| 82 | return true; | 94 | return true; |
| 83 | } | 95 | } |
| 84 | 96 | ||
| @@ -102,6 +114,10 @@ void transport_slave(matrix_row_t matrix[]) { | |||
| 102 | # ifdef ENCODER_ENABLE | 114 | # ifdef ENCODER_ENABLE |
| 103 | encoder_state_raw(i2c_buffer->encoder_state); | 115 | encoder_state_raw(i2c_buffer->encoder_state); |
| 104 | # endif | 116 | # endif |
| 117 | |||
| 118 | # ifdef WPM_ENABLE | ||
| 119 | set_current_wpm(i2c_buffer->current_wpm); | ||
| 120 | # endif | ||
| 105 | } | 121 | } |
| 106 | 122 | ||
| 107 | void transport_master_init(void) { i2c_init(); } | 123 | void transport_master_init(void) { i2c_init(); } |
| @@ -126,6 +142,9 @@ typedef struct _Serial_m2s_buffer_t { | |||
| 126 | # ifdef BACKLIGHT_ENABLE | 142 | # ifdef BACKLIGHT_ENABLE |
| 127 | uint8_t backlight_level; | 143 | uint8_t backlight_level; |
| 128 | # endif | 144 | # endif |
| 145 | # ifdef WPM_ENABLE | ||
| 146 | uint8_t current_wpm; | ||
| 147 | # endif | ||
| 129 | } Serial_m2s_buffer_t; | 148 | } Serial_m2s_buffer_t; |
| 130 | 149 | ||
| 131 | # if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) | 150 | # if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT) |
| @@ -228,6 +247,10 @@ bool transport_master(matrix_row_t matrix[]) { | |||
| 228 | encoder_update_raw((uint8_t *)serial_s2m_buffer.encoder_state); | 247 | encoder_update_raw((uint8_t *)serial_s2m_buffer.encoder_state); |
| 229 | # endif | 248 | # endif |
| 230 | 249 | ||
| 250 | # ifdef WPM_ENABLE | ||
| 251 | // Write wpm to slave | ||
| 252 | serial_m2s_buffer.current_wpm = get_current_wpm(); | ||
| 253 | # endif | ||
| 231 | return true; | 254 | return true; |
| 232 | } | 255 | } |
| 233 | 256 | ||
| @@ -244,6 +267,10 @@ void transport_slave(matrix_row_t matrix[]) { | |||
| 244 | # ifdef ENCODER_ENABLE | 267 | # ifdef ENCODER_ENABLE |
| 245 | encoder_state_raw((uint8_t *)serial_s2m_buffer.encoder_state); | 268 | encoder_state_raw((uint8_t *)serial_s2m_buffer.encoder_state); |
| 246 | # endif | 269 | # endif |
| 270 | |||
| 271 | # ifdef WPM_ENABLE | ||
| 272 | set_current_wpm(serial_m2s_buffer.current_wpm); | ||
| 273 | # endif | ||
| 247 | } | 274 | } |
| 248 | 275 | ||
| 249 | #endif | 276 | #endif |
