diff --git a/keyboards/helix/rev1/keymaps/OLED_sample/serial_config.h b/keyboards/helix/rev1/keymaps/OLED_sample/serial_config.h
index 289a165fa3..b991b874b7 100644
--- a/keyboards/helix/rev1/keymaps/OLED_sample/serial_config.h
+++ b/keyboards/helix/rev1/keymaps/OLED_sample/serial_config.h
@@ -8,6 +8,9 @@
#define SERIAL_PIN_MASK _BV(PD2)
#define SERIAL_PIN_INTERRUPT INT2_vect
+#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
+#define SERIAL_MASTER_BUFFER_LENGTH 0
+
//// #error rev1/keymaps/OLED_sample serial config
#endif /* SOFT_SERIAL_CONFIG_H */
diff --git a/keyboards/helix/rev1/matrix.c b/keyboards/helix/rev1/matrix.c
index 6613c02b00..f2506868ea 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 "split_scomm.h"
+# include "serial.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(1)) {
+ if (serial_update_buffers()) {
return 1;
}
diff --git a/keyboards/helix/rev1/rules.mk b/keyboards/helix/rev1/rules.mk
index 5ecfa33a2a..13834f5da1 100644
--- a/keyboards/helix/rev1/rules.mk
+++ b/keyboards/helix/rev1/rules.mk
@@ -1,5 +1,4 @@
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 f021d6e04b..51c6aa3750 100644
--- a/keyboards/helix/rev1/serial_config.h
+++ b/keyboards/helix/rev1/serial_config.h
@@ -8,6 +8,9 @@
#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 0
+
/// #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
deleted file mode 100644
index a5c0485e30..0000000000
--- a/keyboards/helix/rev1/split_scomm.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#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[] = {
- { (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();
-}
-#endif /* USE_SERIAL */
diff --git a/keyboards/helix/rev1/split_scomm.h b/keyboards/helix/rev1/split_scomm.h
deleted file mode 100644
index c81eff4ffe..0000000000
--- a/keyboards/helix/rev1/split_scomm.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#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 fe17e14f84..5debd6e00b 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 "split_scomm.h"
+# include "serial.h"
#endif
volatile bool isLeftHand = true;
diff --git a/keyboards/helix/rev2/keymaps/default/config.h b/keyboards/helix/rev2/keymaps/default/config.h
index cf9c8e5e39..185e678385 100644
--- a/keyboards/helix/rev2/keymaps/default/config.h
+++ b/keyboards/helix/rev2/keymaps/default/config.h
@@ -22,7 +22,7 @@ along with this program. If not, see .
#define CONFIG_USER_H
// if you need more program area, try uncomment follow line
-//#undef SERIAL_USE_MULTI_TRANSACTION
+//#include "serial_config_simpleapi.h"
// place overrides here
diff --git a/keyboards/helix/rev2/keymaps/edvorakjp/config.h b/keyboards/helix/rev2/keymaps/edvorakjp/config.h
index 51cd1d6417..ead31605b2 100644
--- a/keyboards/helix/rev2/keymaps/edvorakjp/config.h
+++ b/keyboards/helix/rev2/keymaps/edvorakjp/config.h
@@ -2,7 +2,7 @@
#define CONFIG_USER_H
// if you need more program area, try uncomment follow line
-//#undef SERIAL_USE_MULTI_TRANSACTION
+//#include "serial_config_simpleapi.h"
#undef TAPPING_FORCE_HOLD
#undef TAPPING_TERM
diff --git a/keyboards/helix/rev2/keymaps/five_rows/config.h b/keyboards/helix/rev2/keymaps/five_rows/config.h
index 7e7daf0f64..8372194604 100644
--- a/keyboards/helix/rev2/keymaps/five_rows/config.h
+++ b/keyboards/helix/rev2/keymaps/five_rows/config.h
@@ -22,7 +22,7 @@ along with this program. If not, see .
#define CONFIG_USER_H
// if you need more program area, try uncomment follow line
-//#undef SERIAL_USE_MULTI_TRANSACTION
+//#include "serial_config_simpleapi.h"
#undef TAPPING_TERM
#define TAPPING_TERM 140
diff --git a/keyboards/helix/rev2/keymaps/five_rows_jis/config.h b/keyboards/helix/rev2/keymaps/five_rows_jis/config.h
index 8cdfdb4e72..c380b7db4e 100644
--- a/keyboards/helix/rev2/keymaps/five_rows_jis/config.h
+++ b/keyboards/helix/rev2/keymaps/five_rows_jis/config.h
@@ -24,7 +24,7 @@ along with this program. If not, see .
// place overrides here
// if you need more program area, try uncomment follow line
-//#undef SERIAL_USE_MULTI_TRANSACTION
+//#include "serial_config_simpleapi.h"
#ifdef MOUSEKEY_ENABLE
#undef MOUSEKEY_INTERVAL
diff --git a/keyboards/helix/rev2/keymaps/froggy/config.h b/keyboards/helix/rev2/keymaps/froggy/config.h
index a1fea15067..dad2483034 100644
--- a/keyboards/helix/rev2/keymaps/froggy/config.h
+++ b/keyboards/helix/rev2/keymaps/froggy/config.h
@@ -22,7 +22,7 @@ along with this program. If not, see .
#define CONFIG_USER_H
// if you need more program area, try uncomment follow line
-//#undef SERIAL_USE_MULTI_TRANSACTION
+//#include "serial_config_simpleapi.h"
#undef TAPPING_TERM
#define TAPPING_TERM 200
diff --git a/keyboards/helix/rev2/keymaps/led_test/config.h b/keyboards/helix/rev2/keymaps/led_test/config.h
index 56d5f91345..0438254528 100644
--- a/keyboards/helix/rev2/keymaps/led_test/config.h
+++ b/keyboards/helix/rev2/keymaps/led_test/config.h
@@ -22,7 +22,7 @@ along with this program. If not, see .
#define CONFIG_USER_H
// if you need more program area, try uncomment follow line
-#undef SERIAL_USE_MULTI_TRANSACTION
+#include "serial_config_simpleapi.h"
// place overrides here
diff --git a/keyboards/helix/rev2/matrix.c b/keyboards/helix/rev2/matrix.c
index fd64c37ab1..322959dbbb 100644
--- a/keyboards/helix/rev2/matrix.c
+++ b/keyboards/helix/rev2/matrix.c
@@ -183,7 +183,11 @@ i2c_error: // the cable is disconnceted, or something else went wrong
int serial_transaction(int master_changed) {
int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
+#ifdef SERIAL_USE_MULTI_TRANSACTION
int ret=serial_update_buffers(master_changed);
+#else
+ int ret=serial_update_buffers();
+#endif
if (ret ) {
if(ret==2) RXLED1;
return 1;
diff --git a/keyboards/helix/rev2/serial_config_simpleapi.h b/keyboards/helix/rev2/serial_config_simpleapi.h
new file mode 100644
index 0000000000..e2d22a41e7
--- /dev/null
+++ b/keyboards/helix/rev2/serial_config_simpleapi.h
@@ -0,0 +1,8 @@
+#ifndef SERIAL_CONFIG_SIMPLEAPI_H
+#define SERIAL_CONFIG_SIMPLEAPI_H
+
+#undef SERIAL_USE_MULTI_TRANSACTION
+#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
+#define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2
+
+#endif // SERIAL_CONFIG_SIMPLEAPI_H
diff --git a/keyboards/helix/rev2/split_scomm.c b/keyboards/helix/rev2/split_scomm.c
index f37b783d8a..9719eb22ea 100644
--- a/keyboards/helix/rev2/split_scomm.c
+++ b/keyboards/helix/rev2/split_scomm.c
@@ -1,4 +1,7 @@
#ifdef USE_SERIAL
+#ifdef SERIAL_USE_MULTI_TRANSACTION
+/* --- USE flexible API (using multi-type transaction function) --- */
+
#include
#include
#include
@@ -12,19 +15,8 @@ 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 status_com = 0;
uint8_t volatile status1 = 0;
-#ifdef SERIAL_USE_MULTI_TRANSACTION
uint8_t slave_buffer_change_count = 0;
uint8_t s_change_old = 0xff;
-#endif
-
-#ifndef SERIAL_USE_MULTI_TRANSACTION
-SSTD_t transactions[] = {
- { (uint8_t *)&status_com,
- sizeof(serial_master_buffer), (uint8_t *)serial_master_buffer,
- sizeof(serial_slave_buffer), (uint8_t *)serial_slave_buffer
- }
-};
-#else
SSTD_t transactions[] = {
#define GET_SLAVE_STATUS 0
@@ -46,7 +38,6 @@ SSTD_t transactions[] = {
sizeof(serial_slave_buffer), (uint8_t *)serial_slave_buffer
}
};
-#endif
void serial_master_init(void)
{
@@ -63,7 +54,6 @@ void serial_slave_init(void)
// 2 => checksum error
int serial_update_buffers(int master_update)
{
-#ifdef SERIAL_USE_MULTI_TRANSACTION
int status;
static int need_retry = 0;
if( s_change_old != slave_buffer_change_count ) {
@@ -77,10 +67,7 @@ int serial_update_buffers(int master_update)
status = soft_serial_transaction(PUT_MASTER_GET_SLAVE_STATUS);
need_retry = ( status == TRANSACTION_END ) ? 0 : 1;
return status;
-#else
- int status;
- status = soft_serial_transaction();
- return status;
-#endif
}
+
+#endif // SERIAL_USE_MULTI_TRANSACTION
#endif /* USE_SERIAL */
diff --git a/keyboards/helix/rev2/split_scomm.h b/keyboards/helix/rev2/split_scomm.h
index daa680f8d2..873d8939d8 100644
--- a/keyboards/helix/rev2/split_scomm.h
+++ b/keyboards/helix/rev2/split_scomm.h
@@ -1,18 +1,24 @@
#ifndef SPLIT_COMM_H
#define SPLIT_COMM_H
+#ifndef SERIAL_USE_MULTI_TRANSACTION
+/* --- USE Simple API (OLD API, compatible with let's split serial.c) --- */
+#include "serial.h"
+
+#else
+/* --- USE flexible API (using multi-type transaction function) --- */
// Buffers for master - slave communication
#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
#define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2
extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
-#ifdef SERIAL_USE_MULTI_TRANSACTION
extern uint8_t slave_buffer_change_count;
-#endif
void serial_master_init(void);
void serial_slave_init(void);
int serial_update_buffers(int master_changed);
+#endif
+
#endif /* SPLIT_COMM_H */
diff --git a/keyboards/helix/serial.c b/keyboards/helix/serial.c
index b030451248..11ceff0b37 100644
--- a/keyboards/helix/serial.c
+++ b/keyboards/helix/serial.c
@@ -16,6 +16,45 @@
#ifdef USE_SERIAL
+#ifndef SERIAL_USE_MULTI_TRANSACTION
+/* --- USE Simple API (OLD API, compatible with let's split serial.c) */
+ #if SERIAL_SLAVE_BUFFER_LENGTH > 0
+ uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};
+ #endif
+ #if SERIAL_MASTER_BUFFER_LENGTH > 0
+ uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
+ #endif
+ uint8_t volatile status0 = 0;
+
+SSTD_t transactions[] = {
+ { (uint8_t *)&status0,
+ #if SERIAL_MASTER_BUFFER_LENGTH > 0
+ sizeof(serial_master_buffer), (uint8_t *)serial_master_buffer,
+ #else
+ 0, (uint8_t *)NULL,
+ #endif
+ #if SERIAL_SLAVE_BUFFER_LENGTH > 0
+ sizeof(serial_slave_buffer), (uint8_t *)serial_slave_buffer
+ #else
+ 0, (uint8_t *)NULL,
+ #endif
+ }
+};
+
+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()
+{ return soft_serial_transaction(); }
+
+#endif // Simple API (OLD API, compatible with let's split serial.c)
+
#define ALWAYS_INLINE __attribute__((always_inline))
#define NO_INLINE __attribute__((noinline))
#define _delay_sub_us(x) __builtin_avr_delay_cycles(x)
diff --git a/keyboards/helix/serial.h b/keyboards/helix/serial.h
index d3cf1743a3..d2b7fd8e60 100644
--- a/keyboards/helix/serial.h
+++ b/keyboards/helix/serial.h
@@ -3,9 +3,9 @@
#include
-// ////////////////////////////////////////////
+// /////////////////////////////////////////////////////////////////
// Need Soft Serial defines in serial_config.h
-// ////////////////////////////////////////////
+// /////////////////////////////////////////////////////////////////
// ex.
// #define SERIAL_PIN_DDR DDRD
// #define SERIAL_PIN_PORT PORTD
@@ -13,8 +13,31 @@
// #define SERIAL_PIN_MASK _BV(PD?) ?=0,2
// #define SERIAL_PIN_INTERRUPT INT?_vect ?=0,2
//
-// When using multi-type transaction function, define the following macro.
-// #define SERIAL_USE_MULTI_TRANSACTION
+// //// USE Simple API (OLD API, compatible with let's split serial.c)
+// ex.
+// #define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
+// #define SERIAL_MASTER_BUFFER_LENGTH 1
+//
+// //// USE flexible API (using multi-type transaction function)
+// #define SERIAL_USE_MULTI_TRANSACTION
+//
+// /////////////////////////////////////////////////////////////////
+
+
+#ifndef SERIAL_USE_MULTI_TRANSACTION
+/* --- USE Simple API (OLD API, compatible with let's split serial.c) */
+#if SERIAL_SLAVE_BUFFER_LENGTH > 0
+extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
+#endif
+#if SERIAL_MASTER_BUFFER_LENGTH > 0
+extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
+#endif
+
+void serial_master_init(void);
+void serial_slave_init(void);
+int serial_update_buffers(void);
+
+#endif // USE Simple API
// Soft Serial Transaction Descriptor
typedef struct _SSTD_t {