aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--quantum/serial_link/system/serial_link.c22
-rw-r--r--tmk_core/common/sync_timer.c2
-rw-r--r--tmk_core/common/sync_timer.h2
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
36static event_source_t new_data_event; 39static event_source_t new_data_event;
37static bool serial_link_connected; 40static bool serial_link_connected;
38static bool is_master = false; 41static bool is_master = false;
@@ -159,10 +162,16 @@ static matrix_object_t last_matrix = {};
159 162
160SLAVE_TO_MASTER_OBJECT(keyboard_matrix, matrix_object_t); 163SLAVE_TO_MASTER_OBJECT(keyboard_matrix, matrix_object_t);
161MASTER_TO_ALL_SLAVES_OBJECT(serial_link_connected, bool); 164MASTER_TO_ALL_SLAVES_OBJECT(serial_link_connected, bool);
165#ifndef DISABLE_SYNC_TIMER
166MASTER_TO_ALL_SLAVES_OBJECT(sync_timer, uint32_t);
167#endif
162 168
163static remote_object_t* remote_objects[] = { 169static 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
168void init_serial_link(void) { 177void 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
213void signal_data_written(void) { chEvtBroadcast(&new_data_event); } 235void 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)
30volatile int32_t sync_timer_ms; 30volatile int32_t sync_timer_ms;
31 31
32void sync_timer_init(void) { sync_timer_ms = 0; } 32void 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.
32extern "C" { 32extern "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)
36void sync_timer_init(void); 36void sync_timer_init(void);
37void sync_timer_update(uint32_t time); 37void sync_timer_update(uint32_t time);
38uint16_t sync_timer_read(void); 38uint16_t sync_timer_read(void);