diff options
-rw-r--r-- | quantum/serial_link/system/serial_link.c | 22 | ||||
-rw-r--r-- | tmk_core/common/sync_timer.c | 2 | ||||
-rw-r--r-- | tmk_core/common/sync_timer.h | 2 |
3 files changed, 24 insertions, 2 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); } |
diff --git a/tmk_core/common/sync_timer.c b/tmk_core/common/sync_timer.c index de24b463b..68b92d8b4 100644 --- a/tmk_core/common/sync_timer.c +++ b/tmk_core/common/sync_timer.c | |||
@@ -26,7 +26,7 @@ SOFTWARE. | |||
26 | #include "sync_timer.h" | 26 | #include "sync_timer.h" |
27 | #include "keyboard.h" | 27 | #include "keyboard.h" |
28 | 28 | ||
29 | #if defined(SPLIT_KEYBOARD) && !defined(DISABLE_SYNC_TIMER) | 29 | #if (defined(SPLIT_KEYBOARD) || defined(SERIAL_LINK_ENABLE)) && !defined(DISABLE_SYNC_TIMER) |
30 | volatile int32_t sync_timer_ms; | 30 | volatile int32_t sync_timer_ms; |
31 | 31 | ||
32 | void sync_timer_init(void) { sync_timer_ms = 0; } | 32 | void sync_timer_init(void) { sync_timer_ms = 0; } |
diff --git a/tmk_core/common/sync_timer.h b/tmk_core/common/sync_timer.h index 9ddef45bb..744e2b50d 100644 --- a/tmk_core/common/sync_timer.h +++ b/tmk_core/common/sync_timer.h | |||
@@ -32,7 +32,7 @@ SOFTWARE. | |||
32 | extern "C" { | 32 | extern "C" { |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | #if defined(SPLIT_KEYBOARD) && !defined(DISABLE_SYNC_TIMER) | 35 | #if (defined(SPLIT_KEYBOARD) || defined(SERIAL_LINK_ENABLE)) && !defined(DISABLE_SYNC_TIMER) |
36 | void sync_timer_init(void); | 36 | void sync_timer_init(void); |
37 | void sync_timer_update(uint32_t time); | 37 | void sync_timer_update(uint32_t time); |
38 | uint16_t sync_timer_read(void); | 38 | uint16_t sync_timer_read(void); |