diff options
Diffstat (limited to 'quantum/split_common/transactions.h')
-rw-r--r-- | quantum/split_common/transactions.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/quantum/split_common/transactions.h b/quantum/split_common/transactions.h new file mode 100644 index 000000000..4306ba1d8 --- /dev/null +++ b/quantum/split_common/transactions.h | |||
@@ -0,0 +1,54 @@ | |||
1 | /* Copyright 2021 QMK | ||
2 | * | ||
3 | * This program is free software: you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License as published by | ||
5 | * the Free Software Foundation, either version 2 of the License, or | ||
6 | * (at your option) any later version. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #pragma once | ||
18 | |||
19 | #include "stdint.h" | ||
20 | #include "stdbool.h" | ||
21 | |||
22 | #include "matrix.h" | ||
23 | #include "transaction_id_define.h" | ||
24 | #include "transport.h" | ||
25 | |||
26 | typedef void (*slave_callback_t)(uint8_t initiator2target_buffer_size, const void *initiator2target_buffer, uint8_t target2initiator_buffer_size, void *target2initiator_buffer); | ||
27 | |||
28 | // Split transaction Descriptor | ||
29 | typedef struct _split_transaction_desc_t { | ||
30 | uint8_t * status; | ||
31 | uint8_t initiator2target_buffer_size; | ||
32 | uint16_t initiator2target_offset; | ||
33 | uint8_t target2initiator_buffer_size; | ||
34 | uint16_t target2initiator_offset; | ||
35 | slave_callback_t slave_callback; | ||
36 | } split_transaction_desc_t; | ||
37 | |||
38 | // Forward declaration for the split transactions | ||
39 | extern split_transaction_desc_t split_transaction_table[NUM_TOTAL_TRANSACTIONS]; | ||
40 | |||
41 | #define split_shmem_offset_ptr(offset) ((void *)(((uint8_t *)split_shmem) + (offset))) | ||
42 | #define split_trans_initiator2target_buffer(trans) (split_shmem_offset_ptr((trans)->initiator2target_offset)) | ||
43 | #define split_trans_target2initiator_buffer(trans) (split_shmem_offset_ptr((trans)->target2initiator_offset)) | ||
44 | |||
45 | // returns false if valid data not received from slave | ||
46 | bool transactions_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]); | ||
47 | void transactions_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]); | ||
48 | |||
49 | void transaction_register_rpc(int8_t transaction_id, slave_callback_t callback); | ||
50 | |||
51 | bool transaction_rpc_exec(int8_t transaction_id, uint8_t initiator2target_buffer_size, const void *initiator2target_buffer, uint8_t target2initiator_buffer_size, void *target2initiator_buffer); | ||
52 | |||
53 | #define transaction_rpc_send(transaction_id, initiator2target_buffer_size, initiator2target_buffer) transaction_rpc_exec(transaction_id, initiator2target_buffer_size, initiator2target_buffer, 0, NULL) | ||
54 | #define transaction_rpc_recv(transaction_id, target2initiator_buffer_size, target2initiator_buffer) transaction_rpc_exec(transaction_id, 0, NULL, target2initiator_buffer_size, target2initiator_buffer) | ||