You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

235 lines
7.4 KiB

Simplify split_common Code significantly (#4772) * Eliminate separate slave loop Both master and slave run the standard keyboard_task main loop now. * Refactor i2c/serial specific code Simplify some of the preprocessor mess by using common function names. * Fix missing #endif * Move direct pin mapping support from miniaxe to split_common For boards with more pins than sense--sorry, switches. * Reordering and reformatting only * Don't run matrix_scan_quantum on slave side * Clean up the offset/slaveOffset calculations * Cut undebounced matrix size in half * Refactor debouncing * Minor fixups * Split split_common transport and debounce code into their own files Can now be replaced with custom versions per keyboard using CUSTOM_TRANSPORT = yes and CUSTOM_DEBOUNCE = yes * Refactor debounce for non-split keyboards too * Update handwired/xealous to build using new split_common * Fix debounce breaking basic test * Dodgy method to allow a split kb to only include one of i2c/serial SPLIT_TRANSPORT = serial or SPLIT_TRANSPORT = i2c will include only that driver code in the binary. SPLIT_TRANSPORT = custom (or anything else) will include neither, the keyboard must supply it's own code if SPLIT_TRANSPORT is not defined then the original behaviour (include both avr i2c and serial code) is maintained. This could be better but it would require explicitly updating all the existing split keyboards. * Enable LTO to get lets_split/sockets under the line * Add docs for SPLIT_TRANSPORT, CUSTOM_MATRIX, CUSTOM_DEBOUNCE * Remove avr-specific sei() from split matrix_setup Not needed now that slave doesn't have a separate main loop. Both sides (on avr) call sei() in lufa's main() after exiting keyboard_setup(). * Fix QUANTUM_LIB_SRC references and simplify SPLIT_TRANSPORT. * Add comments and fix formatting.
5 years ago
Simplify split_common Code significantly (#4772) * Eliminate separate slave loop Both master and slave run the standard keyboard_task main loop now. * Refactor i2c/serial specific code Simplify some of the preprocessor mess by using common function names. * Fix missing #endif * Move direct pin mapping support from miniaxe to split_common For boards with more pins than sense--sorry, switches. * Reordering and reformatting only * Don't run matrix_scan_quantum on slave side * Clean up the offset/slaveOffset calculations * Cut undebounced matrix size in half * Refactor debouncing * Minor fixups * Split split_common transport and debounce code into their own files Can now be replaced with custom versions per keyboard using CUSTOM_TRANSPORT = yes and CUSTOM_DEBOUNCE = yes * Refactor debounce for non-split keyboards too * Update handwired/xealous to build using new split_common * Fix debounce breaking basic test * Dodgy method to allow a split kb to only include one of i2c/serial SPLIT_TRANSPORT = serial or SPLIT_TRANSPORT = i2c will include only that driver code in the binary. SPLIT_TRANSPORT = custom (or anything else) will include neither, the keyboard must supply it's own code if SPLIT_TRANSPORT is not defined then the original behaviour (include both avr i2c and serial code) is maintained. This could be better but it would require explicitly updating all the existing split keyboards. * Enable LTO to get lets_split/sockets under the line * Add docs for SPLIT_TRANSPORT, CUSTOM_MATRIX, CUSTOM_DEBOUNCE * Remove avr-specific sei() from split matrix_setup Not needed now that slave doesn't have a separate main loop. Both sides (on avr) call sei() in lufa's main() after exiting keyboard_setup(). * Fix QUANTUM_LIB_SRC references and simplify SPLIT_TRANSPORT. * Add comments and fix formatting.
5 years ago
Simplify split_common Code significantly (#4772) * Eliminate separate slave loop Both master and slave run the standard keyboard_task main loop now. * Refactor i2c/serial specific code Simplify some of the preprocessor mess by using common function names. * Fix missing #endif * Move direct pin mapping support from miniaxe to split_common For boards with more pins than sense--sorry, switches. * Reordering and reformatting only * Don't run matrix_scan_quantum on slave side * Clean up the offset/slaveOffset calculations * Cut undebounced matrix size in half * Refactor debouncing * Minor fixups * Split split_common transport and debounce code into their own files Can now be replaced with custom versions per keyboard using CUSTOM_TRANSPORT = yes and CUSTOM_DEBOUNCE = yes * Refactor debounce for non-split keyboards too * Update handwired/xealous to build using new split_common * Fix debounce breaking basic test * Dodgy method to allow a split kb to only include one of i2c/serial SPLIT_TRANSPORT = serial or SPLIT_TRANSPORT = i2c will include only that driver code in the binary. SPLIT_TRANSPORT = custom (or anything else) will include neither, the keyboard must supply it's own code if SPLIT_TRANSPORT is not defined then the original behaviour (include both avr i2c and serial code) is maintained. This could be better but it would require explicitly updating all the existing split keyboards. * Enable LTO to get lets_split/sockets under the line * Add docs for SPLIT_TRANSPORT, CUSTOM_MATRIX, CUSTOM_DEBOUNCE * Remove avr-specific sei() from split matrix_setup Not needed now that slave doesn't have a separate main loop. Both sides (on avr) call sei() in lufa's main() after exiting keyboard_setup(). * Fix QUANTUM_LIB_SRC references and simplify SPLIT_TRANSPORT. * Add comments and fix formatting.
5 years ago
  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. #pragma once
  17. #include <stdint.h>
  18. #include <stdbool.h>
  19. #include "progmem.h"
  20. #include "action_layer.h"
  21. #include "matrix.h"
  22. #ifndef RPC_M2S_BUFFER_SIZE
  23. # define RPC_M2S_BUFFER_SIZE 32
  24. #endif // RPC_M2S_BUFFER_SIZE
  25. #ifndef RPC_S2M_BUFFER_SIZE
  26. # define RPC_S2M_BUFFER_SIZE 32
  27. #endif // RPC_S2M_BUFFER_SIZE
  28. void transport_master_init(void);
  29. void transport_slave_init(void);
  30. // returns false if valid data not received from slave
  31. bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]);
  32. void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]);
  33. bool transport_execute_transaction(int8_t id, const void *initiator2target_buf, uint16_t initiator2target_length, void *target2initiator_buf, uint16_t target2initiator_length);
  34. #ifdef ENCODER_ENABLE
  35. # include "encoder.h"
  36. #endif // ENCODER_ENABLE
  37. #ifdef BACKLIGHT_ENABLE
  38. # include "backlight.h"
  39. #endif // BACKLIGHT_ENABLE
  40. #ifdef RGBLIGHT_ENABLE
  41. # include "rgblight.h"
  42. #endif // RGBLIGHT_ENABLE
  43. typedef struct _split_slave_matrix_sync_t {
  44. uint8_t checksum;
  45. matrix_row_t matrix[(MATRIX_ROWS) / 2];
  46. } split_slave_matrix_sync_t;
  47. #ifdef SPLIT_TRANSPORT_MIRROR
  48. typedef struct _split_master_matrix_sync_t {
  49. matrix_row_t matrix[(MATRIX_ROWS) / 2];
  50. } split_master_matrix_sync_t;
  51. #endif // SPLIT_TRANSPORT_MIRROR
  52. #ifdef ENCODER_ENABLE
  53. typedef struct _split_slave_encoder_sync_t {
  54. uint8_t checksum;
  55. encoder_events_t events;
  56. } split_slave_encoder_sync_t;
  57. #endif // ENCODER_ENABLE
  58. #if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
  59. typedef struct _split_layers_sync_t {
  60. layer_state_t layer_state;
  61. layer_state_t default_layer_state;
  62. } split_layers_sync_t;
  63. #endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
  64. #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
  65. # include "led_matrix.h"
  66. typedef struct _led_matrix_sync_t {
  67. led_eeconfig_t led_matrix;
  68. bool led_suspend_state;
  69. } led_matrix_sync_t;
  70. #endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
  71. #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
  72. # include "rgb_matrix.h"
  73. typedef struct _rgb_matrix_sync_t {
  74. rgb_config_t rgb_matrix;
  75. bool rgb_suspend_state;
  76. } rgb_matrix_sync_t;
  77. #endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
  78. #ifdef SPLIT_MODS_ENABLE
  79. typedef struct _split_mods_sync_t {
  80. uint8_t real_mods;
  81. uint8_t weak_mods;
  82. # ifndef NO_ACTION_ONESHOT
  83. uint8_t oneshot_mods;
  84. # endif // NO_ACTION_ONESHOT
  85. } split_mods_sync_t;
  86. #endif // SPLIT_MODS_ENABLE
  87. #if defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
  88. # include "pointing_device.h"
  89. typedef struct _split_slave_pointing_sync_t {
  90. uint8_t checksum;
  91. report_mouse_t report;
  92. uint16_t cpi;
  93. } split_slave_pointing_sync_t;
  94. #endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
  95. #if defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE)
  96. # include "haptic.h"
  97. typedef struct _split_slave_haptic_sync_t {
  98. haptic_config_t haptic_config;
  99. uint8_t haptic_play;
  100. } split_slave_haptic_sync_t;
  101. #endif // defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE)
  102. #if defined(SPLIT_ACTIVITY_ENABLE)
  103. # include "keyboard.h"
  104. typedef struct _split_slave_activity_sync_t {
  105. uint32_t matrix_timestamp;
  106. uint32_t encoder_timestamp;
  107. uint32_t pointing_device_timestamp;
  108. } split_slave_activity_sync_t;
  109. #endif // defined(SPLIT_ACTIVITY_ENABLE)
  110. #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
  111. typedef struct _rpc_sync_info_t {
  112. uint8_t checksum;
  113. struct {
  114. int8_t transaction_id;
  115. uint8_t m2s_length;
  116. uint8_t s2m_length;
  117. } payload;
  118. } rpc_sync_info_t;
  119. #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
  120. #if defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
  121. # include "os_detection.h"
  122. #endif // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
  123. typedef struct _split_shared_memory_t {
  124. #ifdef USE_I2C
  125. int8_t transaction_id;
  126. #endif // USE_I2C
  127. split_slave_matrix_sync_t smatrix;
  128. #ifdef SPLIT_TRANSPORT_MIRROR
  129. split_master_matrix_sync_t mmatrix;
  130. #endif // SPLIT_TRANSPORT_MIRROR
  131. #ifdef ENCODER_ENABLE
  132. split_slave_encoder_sync_t encoders;
  133. #endif // ENCODER_ENABLE
  134. #ifndef DISABLE_SYNC_TIMER
  135. uint32_t sync_timer;
  136. #endif // DISABLE_SYNC_TIMER
  137. #if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
  138. split_layers_sync_t layers;
  139. #endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
  140. #ifdef SPLIT_LED_STATE_ENABLE
  141. uint8_t led_state;
  142. #endif // SPLIT_LED_STATE_ENABLE
  143. #ifdef SPLIT_MODS_ENABLE
  144. split_mods_sync_t mods;
  145. #endif // SPLIT_MODS_ENABLE
  146. #ifdef BACKLIGHT_ENABLE
  147. uint8_t backlight_level;
  148. #endif // BACKLIGHT_ENABLE
  149. #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
  150. rgblight_syncinfo_t rgblight_sync;
  151. #endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
  152. #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
  153. led_matrix_sync_t led_matrix_sync;
  154. #endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
  155. #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
  156. rgb_matrix_sync_t rgb_matrix_sync;
  157. #endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
  158. #if defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE)
  159. uint8_t current_wpm;
  160. #endif // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE)
  161. #if defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE)
  162. uint8_t current_oled_state;
  163. #endif // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE)
  164. #if defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE)
  165. uint8_t current_st7565_state;
  166. #endif // ST7565_ENABLE(OLED_ENABLE) && defined(SPLIT_ST7565_ENABLE)
  167. #if defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
  168. split_slave_pointing_sync_t pointing;
  169. #endif // defined(POINTING_DEVICE_ENABLE) && defined(SPLIT_POINTING_ENABLE)
  170. #if defined(SPLIT_WATCHDOG_ENABLE)
  171. bool watchdog_pinged;
  172. #endif // defined(SPLIT_WATCHDOG_ENABLE)
  173. #if defined(HAPTIC_ENABLE) && defined(SPLIT_HAPTIC_ENABLE)
  174. split_slave_haptic_sync_t haptic_sync;
  175. #endif // defined(HAPTIC_ENABLE)
  176. #if defined(SPLIT_ACTIVITY_ENABLE)
  177. split_slave_activity_sync_t activity_sync;
  178. #endif // defined(SPLIT_ACTIVITY_ENABLE)
  179. #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
  180. rpc_sync_info_t rpc_info;
  181. uint8_t rpc_m2s_buffer[RPC_M2S_BUFFER_SIZE];
  182. uint8_t rpc_s2m_buffer[RPC_S2M_BUFFER_SIZE];
  183. #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
  184. #if defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
  185. os_variant_t detected_os;
  186. #endif // defined(OS_DETECTION_ENABLE) && defined(SPLIT_DETECTED_OS_ENABLE)
  187. } split_shared_memory_t;
  188. extern split_shared_memory_t *const split_shmem;