diff options
Diffstat (limited to 'quantum/serial_link')
| -rw-r--r-- | quantum/serial_link/system/serial_link.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/quantum/serial_link/system/serial_link.c b/quantum/serial_link/system/serial_link.c index f77483ad8..6363f8ff3 100644 --- a/quantum/serial_link/system/serial_link.c +++ b/quantum/serial_link/system/serial_link.c | |||
| @@ -29,10 +29,13 @@ SOFTWARE. | |||
| 29 | #include "serial_link/protocol/transport.h" | 29 | #include "serial_link/protocol/transport.h" |
| 30 | #include "serial_link/protocol/frame_router.h" | 30 | #include "serial_link/protocol/frame_router.h" |
| 31 | #include "matrix.h" | 31 | #include "matrix.h" |
| 32 | #include "sync_timer.h" | ||
| 32 | #include <stdbool.h> | 33 | #include <stdbool.h> |
| 33 | #include "print.h" | 34 | #include "print.h" |
| 34 | #include "config.h" | 35 | #include "config.h" |
| 35 | 36 | ||
| 37 | #define SYNC_TIMER_OFFSET 2 | ||
| 38 | |||
| 36 | static event_source_t new_data_event; | 39 | static event_source_t new_data_event; |
| 37 | static bool serial_link_connected; | 40 | static bool serial_link_connected; |
| 38 | static bool is_master = false; | 41 | static bool is_master = false; |
| @@ -159,10 +162,16 @@ static matrix_object_t last_matrix = {}; | |||
| 159 | 162 | ||
| 160 | SLAVE_TO_MASTER_OBJECT(keyboard_matrix, matrix_object_t); | 163 | SLAVE_TO_MASTER_OBJECT(keyboard_matrix, matrix_object_t); |
| 161 | MASTER_TO_ALL_SLAVES_OBJECT(serial_link_connected, bool); | 164 | MASTER_TO_ALL_SLAVES_OBJECT(serial_link_connected, bool); |
| 165 | #ifndef DISABLE_SYNC_TIMER | ||
| 166 | MASTER_TO_ALL_SLAVES_OBJECT(sync_timer, uint32_t); | ||
| 167 | #endif | ||
| 162 | 168 | ||
| 163 | static remote_object_t* remote_objects[] = { | 169 | static remote_object_t* remote_objects[] = { |
| 164 | REMOTE_OBJECT(serial_link_connected), | 170 | REMOTE_OBJECT(serial_link_connected), |
| 165 | REMOTE_OBJECT(keyboard_matrix), | 171 | REMOTE_OBJECT(keyboard_matrix), |
| 172 | #ifndef DISABLE_SYNC_TIMER | ||
| 173 | REMOTE_OBJECT(sync_timer), | ||
| 174 | #endif | ||
| 166 | }; | 175 | }; |
| 167 | 176 | ||
| 168 | void init_serial_link(void) { | 177 | void init_serial_link(void) { |
| @@ -200,14 +209,27 @@ void serial_link_update(void) { | |||
| 200 | m->rows[i] = matrix.rows[i]; | 209 | m->rows[i] = matrix.rows[i]; |
| 201 | } | 210 | } |
| 202 | end_write_keyboard_matrix(); | 211 | end_write_keyboard_matrix(); |
| 212 | |||
| 203 | *begin_write_serial_link_connected() = true; | 213 | *begin_write_serial_link_connected() = true; |
| 204 | end_write_serial_link_connected(); | 214 | end_write_serial_link_connected(); |
| 215 | |||
| 216 | #ifndef DISABLE_SYNC_TIMER | ||
| 217 | *begin_write_sync_timer() = sync_timer_read32() + SYNC_TIMER_OFFSET; | ||
| 218 | end_write_sync_timer(); | ||
| 219 | #endif | ||
| 205 | } | 220 | } |
| 206 | 221 | ||
| 207 | matrix_object_t* m = read_keyboard_matrix(0); | 222 | matrix_object_t* m = read_keyboard_matrix(0); |
| 208 | if (m) { | 223 | if (m) { |
| 209 | matrix_set_remote(m->rows, 0); | 224 | matrix_set_remote(m->rows, 0); |
| 210 | } | 225 | } |
| 226 | |||
| 227 | #ifndef DISABLE_SYNC_TIMER | ||
| 228 | uint32_t* t = read_sync_timer(); | ||
| 229 | if (t) { | ||
| 230 | sync_timer_update(*t); | ||
| 231 | } | ||
| 232 | #endif | ||
| 211 | } | 233 | } |
| 212 | 234 | ||
| 213 | void signal_data_written(void) { chEvtBroadcast(&new_data_event); } | 235 | void signal_data_written(void) { chEvtBroadcast(&new_data_event); } |
