diff options
| author | Nick Brassel <nick@tzarc.org> | 2021-06-18 09:10:06 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-18 09:10:06 +1000 |
| commit | 172e6a703041363decd6fc829542f33180c13beb (patch) | |
| tree | a5d4afaa672ab44826865fd76b201e3899083192 /quantum/split_common/transactions.h | |
| parent | ef92c9ee2cf4745637635ec1895399e4f013914c (diff) | |
| download | qmk_firmware-172e6a703041363decd6fc829542f33180c13beb.tar.gz qmk_firmware-172e6a703041363decd6fc829542f33180c13beb.zip | |
Extensible split data sync (#11930)
* Extensible split data sync capability through transactions.
- Split common transport has been split up between the transport layer
and data layer.
- Split "transactions" model used, with convergence between I2C and
serial data definitions.
- Slave matrix "generation count" is used to determine if the full slave
matrix needs to be retrieved.
- Encoders get the same "generation count" treatment.
- All other blocks of data are synchronised when a change is detected.
- All transmissions have a globally-configurable deadline before a
transmission is forced (`FORCED_SYNC_THROTTLE_MS`, default 100ms).
- Added atomicity for all core-synced data, preventing partial updates
- Added retries to AVR i2c_master's i2c_start, to minimise the number of
failed transactions when interrupts are disabled on the slave due to
atomicity checks.
- Some keyboards have had slight modifications made in order to ensure
that they still build due to firmware size restrictions.
* Fixup LED_MATRIX compile.
* Parameterise ERROR_DISCONNECT_COUNT.
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) | ||
