diff options
Diffstat (limited to 'quantum/split_common')
-rw-r--r-- | quantum/split_common/transactions.c | 21 | ||||
-rw-r--r-- | quantum/split_common/transport.h | 3 |
2 files changed, 11 insertions, 13 deletions
diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c index cffbccaeee..9e3df534e3 100644 --- a/quantum/split_common/transactions.c +++ b/quantum/split_common/transactions.c @@ -23,8 +23,9 @@ #include "quantum.h" #include "transactions.h" #include "transport.h" -#include "split_util.h" #include "transaction_id_define.h" +#include "split_util.h" +#include "synchronization_util.h" #define SYNC_TIMER_OFFSET 2 @@ -63,9 +64,7 @@ static bool transaction_handler_master(matrix_row_t master_matrix[], matrix_row_ } } bool this_okay = true; - ATOMIC_BLOCK_FORCEON { - this_okay = handler(master_matrix, slave_matrix); - }; + this_okay = handler(master_matrix, slave_matrix); if (this_okay) return true; } dprintf("Failed to execute %s\n", prefix); @@ -77,11 +76,11 @@ static bool transaction_handler_master(matrix_row_t master_matrix[], matrix_row_ if (!transaction_handler_master(master_matrix, slave_matrix, #prefix, &prefix##_handlers_master)) return false; \ } while (0) -#define TRANSACTION_HANDLER_SLAVE(prefix) \ - do { \ - ATOMIC_BLOCK_FORCEON { \ - prefix##_handlers_slave(master_matrix, slave_matrix); \ - }; \ +#define TRANSACTION_HANDLER_SLAVE(prefix) \ + do { \ + split_shared_memory_lock(); \ + prefix##_handlers_slave(master_matrix, slave_matrix); \ + split_shared_memory_unlock(); \ } while (0) inline static bool read_if_checksum_mismatch(int8_t trans_id_checksum, int8_t trans_id_retrieve, uint32_t *last_update, void *destination, const void *equiv_shmem, size_t length) { @@ -180,7 +179,7 @@ static void master_matrix_handlers_slave(matrix_row_t master_matrix[], matrix_ro static bool encoder_handlers_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { static uint32_t last_update = 0; - uint8_t temp_state[NUMBER_OF_ENCODERS]; + uint8_t temp_state[NUM_ENCODERS_MAX_PER_SIDE]; bool okay = read_if_checksum_mismatch(GET_ENCODERS_CHECKSUM, GET_ENCODERS_DATA, &last_update, temp_state, split_shmem->encoders.state, sizeof(temp_state)); if (okay) encoder_update_raw(temp_state); @@ -188,7 +187,7 @@ static bool encoder_handlers_master(matrix_row_t master_matrix[], matrix_row_t s } static void encoder_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { - uint8_t encoder_state[NUMBER_OF_ENCODERS]; + uint8_t encoder_state[NUM_ENCODERS_MAX_PER_SIDE]; encoder_state_raw(encoder_state); // Always prepare the encoder state for read. memcpy(split_shmem->encoders.state, encoder_state, sizeof(encoder_state)); diff --git a/quantum/split_common/transport.h b/quantum/split_common/transport.h index 26bd136728..e62679990a 100644 --- a/quantum/split_common/transport.h +++ b/quantum/split_common/transport.h @@ -42,7 +42,6 @@ bool transport_execute_transaction(int8_t id, const void *initiator2target_buf, #ifdef ENCODER_ENABLE # include "encoder.h" -# define NUMBER_OF_ENCODERS (sizeof((pin_t[])ENCODERS_PAD_A) / sizeof(pin_t)) #endif // ENCODER_ENABLE #ifdef BACKLIGHT_ENABLE @@ -67,7 +66,7 @@ typedef struct _split_master_matrix_sync_t { #ifdef ENCODER_ENABLE typedef struct _split_slave_encoder_sync_t { uint8_t checksum; - uint8_t state[NUMBER_OF_ENCODERS]; + uint8_t state[NUM_ENCODERS_MAX_PER_SIDE]; } split_slave_encoder_sync_t; #endif // ENCODER_ENABLE |