From bae4bfe9d7f99b4374ca55638e047704051fa142 Mon Sep 17 00:00:00 2001
From: mtei <2170248+mtei@users.noreply.github.com>
Date: Sat, 21 Jul 2018 19:05:15 +0900
Subject: [PATCH] add split_scomm.c/split_scomm.h into helix/rev1
---
keyboards/helix/rev1/matrix.c | 4 +--
keyboards/helix/rev1/rules.mk | 5 ++--
keyboards/helix/rev1/serial_config.h | 3 ---
keyboards/helix/rev1/split_scomm.c | 38 ++++++++++++++++++++++++++++
keyboards/helix/rev1/split_scomm.h | 15 +++++++++++
keyboards/helix/rev1/split_util.c | 2 +-
keyboards/helix/rev2/split_scomm.c | 4 ++-
7 files changed, 62 insertions(+), 9 deletions(-)
create mode 100644 keyboards/helix/rev1/split_scomm.c
create mode 100644 keyboards/helix/rev1/split_scomm.h
diff --git a/keyboards/helix/rev1/matrix.c b/keyboards/helix/rev1/matrix.c
index f2506868ea..6613c02b00 100644
--- a/keyboards/helix/rev1/matrix.c
+++ b/keyboards/helix/rev1/matrix.c
@@ -35,7 +35,7 @@ along with this program. If not, see .
#ifdef USE_MATRIX_I2C
# include "i2c.h"
#else // USE_SERIAL
-# include "serial.h"
+# include "split_scomm.h"
#endif
#ifndef DEBOUNCE
@@ -178,7 +178,7 @@ i2c_error: // the cable is disconnceted, or something else went wrong
int serial_transaction(void) {
int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
- if (serial_update_buffers()) {
+ if (serial_update_buffers(1)) {
return 1;
}
diff --git a/keyboards/helix/rev1/rules.mk b/keyboards/helix/rev1/rules.mk
index daba80eaea..5ecfa33a2a 100644
--- a/keyboards/helix/rev1/rules.mk
+++ b/keyboards/helix/rev1/rules.mk
@@ -1,4 +1,5 @@
-SRC += rev1/matrix.c \
- rev1/split_util.c
+SRC += rev1/matrix.c
+SRC += rev1/split_util.c
+SRC += rev1/split_scomm.c
BACKLIGHT_ENABLE = no
diff --git a/keyboards/helix/rev1/serial_config.h b/keyboards/helix/rev1/serial_config.h
index 2b668a6afc..f021d6e04b 100644
--- a/keyboards/helix/rev1/serial_config.h
+++ b/keyboards/helix/rev1/serial_config.h
@@ -8,9 +8,6 @@
#define SERIAL_PIN_MASK _BV(PD0)
#define SERIAL_PIN_INTERRUPT INT0_vect
-#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
-#define SERIAL_MASTER_BUFFER_LENGTH 1
-
/// #error rev1 serial config
#endif /* SOFT_SERIAL_CONFIG_H */
diff --git a/keyboards/helix/rev1/split_scomm.c b/keyboards/helix/rev1/split_scomm.c
new file mode 100644
index 0000000000..14491abe84
--- /dev/null
+++ b/keyboards/helix/rev1/split_scomm.c
@@ -0,0 +1,38 @@
+#ifdef USE_SERIAL
+#include
+#include
+#include
+#include
+#include "serial.h"
+
+uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};
+uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
+uint8_t volatile status0 = 0;
+
+SSTD_t transactions[] = {
+
+#define WHOLE_MATRIX_EXCHANGE 0
+ { (uint8_t *)&status0,
+ sizeof(serial_master_buffer), (uint8_t *)serial_master_buffer,
+ sizeof(serial_slave_buffer), (uint8_t *)serial_slave_buffer
+ }
+};
+
+void serial_master_init(void)
+{
+ soft_serial_initiator_init(transactions);
+}
+
+void serial_slave_init(void)
+{
+ soft_serial_target_init(transactions);
+}
+
+// 0 => no error
+// 1 => slave did not respond
+// 2 => checksum error
+int serial_update_buffers(int master_update)
+{
+ return soft_serial_transaction(WHOLE_MATRIX_EXCHANGE);
+}
+#endif /* USE_SERIAL */
diff --git a/keyboards/helix/rev1/split_scomm.h b/keyboards/helix/rev1/split_scomm.h
new file mode 100644
index 0000000000..c81eff4ffe
--- /dev/null
+++ b/keyboards/helix/rev1/split_scomm.h
@@ -0,0 +1,15 @@
+#ifndef SPLIT_COMM_H
+#define SPLIT_COMM_H
+
+// Buffers for master - slave communication
+#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
+#define SERIAL_MASTER_BUFFER_LENGTH 1
+
+extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
+extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
+
+void serial_master_init(void);
+void serial_slave_init(void);
+int serial_update_buffers(int master_changed);
+
+#endif /* SPLIT_COMM_H */
diff --git a/keyboards/helix/rev1/split_util.c b/keyboards/helix/rev1/split_util.c
index 5debd6e00b..fe17e14f84 100644
--- a/keyboards/helix/rev1/split_util.c
+++ b/keyboards/helix/rev1/split_util.c
@@ -12,7 +12,7 @@
#ifdef USE_MATRIX_I2C
# include "i2c.h"
#else
-# include "serial.h"
+# include "split_scomm.h"
#endif
volatile bool isLeftHand = true;
diff --git a/keyboards/helix/rev2/split_scomm.c b/keyboards/helix/rev2/split_scomm.c
index e7d97310ed..14491abe84 100644
--- a/keyboards/helix/rev2/split_scomm.c
+++ b/keyboards/helix/rev2/split_scomm.c
@@ -10,6 +10,8 @@ uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
uint8_t volatile status0 = 0;
SSTD_t transactions[] = {
+
+#define WHOLE_MATRIX_EXCHANGE 0
{ (uint8_t *)&status0,
sizeof(serial_master_buffer), (uint8_t *)serial_master_buffer,
sizeof(serial_slave_buffer), (uint8_t *)serial_slave_buffer
@@ -31,6 +33,6 @@ void serial_slave_init(void)
// 2 => checksum error
int serial_update_buffers(int master_update)
{
- return soft_serial_transaction(0);
+ return soft_serial_transaction(WHOLE_MATRIX_EXCHANGE);
}
#endif /* USE_SERIAL */