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.

188 lines
5.9 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 "gpio.h"
  36. # include "encoder.h"
  37. // if no pads for right half are defined, we assume the keyboard is symmetric (i.e. same pads)
  38. # ifndef ENCODERS_PAD_A_RIGHT
  39. # define ENCODERS_PAD_A_RIGHT ENCODERS_PAD_A
  40. # endif
  41. # define NUMBER_OF_ENCODERS ((sizeof((pin_t[])ENCODERS_PAD_A) + sizeof((pin_t[])ENCODERS_PAD_A_RIGHT)) / sizeof(pin_t))
  42. #endif // ENCODER_ENABLE
  43. #ifdef BACKLIGHT_ENABLE
  44. # include "backlight.h"
  45. #endif // BACKLIGHT_ENABLE
  46. #ifdef RGBLIGHT_ENABLE
  47. # include "rgblight.h"
  48. #endif // RGBLIGHT_ENABLE
  49. typedef struct _split_slave_matrix_sync_t {
  50. uint8_t checksum;
  51. matrix_row_t matrix[(MATRIX_ROWS) / 2];
  52. } split_slave_matrix_sync_t;
  53. #ifdef SPLIT_TRANSPORT_MIRROR
  54. typedef struct _split_master_matrix_sync_t {
  55. matrix_row_t matrix[(MATRIX_ROWS) / 2];
  56. } split_master_matrix_sync_t;
  57. #endif // SPLIT_TRANSPORT_MIRROR
  58. #ifdef ENCODER_ENABLE
  59. typedef struct _split_slave_encoder_sync_t {
  60. uint8_t checksum;
  61. uint8_t state[NUMBER_OF_ENCODERS];
  62. } split_slave_encoder_sync_t;
  63. #endif // ENCODER_ENABLE
  64. #if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
  65. typedef struct _split_layers_sync_t {
  66. layer_state_t layer_state;
  67. layer_state_t default_layer_state;
  68. } split_layers_sync_t;
  69. #endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
  70. #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
  71. # include "led_matrix.h"
  72. typedef struct _led_matrix_sync_t {
  73. led_eeconfig_t led_matrix;
  74. bool led_suspend_state;
  75. } led_matrix_sync_t;
  76. #endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
  77. #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
  78. # include "rgb_matrix.h"
  79. typedef struct _rgb_matrix_sync_t {
  80. rgb_config_t rgb_matrix;
  81. bool rgb_suspend_state;
  82. } rgb_matrix_sync_t;
  83. #endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
  84. #ifdef SPLIT_MODS_ENABLE
  85. typedef struct _split_mods_sync_t {
  86. uint8_t real_mods;
  87. uint8_t weak_mods;
  88. # ifndef NO_ACTION_ONESHOT
  89. uint8_t oneshot_mods;
  90. # endif // NO_ACTION_ONESHOT
  91. } split_mods_sync_t;
  92. #endif // SPLIT_MODS_ENABLE
  93. #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
  94. typedef struct _rpc_sync_info_t {
  95. int8_t transaction_id;
  96. uint8_t m2s_length;
  97. uint8_t s2m_length;
  98. } rpc_sync_info_t;
  99. #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
  100. typedef struct _split_shared_memory_t {
  101. #ifdef USE_I2C
  102. int8_t transaction_id;
  103. #endif // USE_I2C
  104. split_slave_matrix_sync_t smatrix;
  105. #ifdef SPLIT_TRANSPORT_MIRROR
  106. split_master_matrix_sync_t mmatrix;
  107. #endif // SPLIT_TRANSPORT_MIRROR
  108. #ifdef ENCODER_ENABLE
  109. split_slave_encoder_sync_t encoders;
  110. #endif // ENCODER_ENABLE
  111. #ifndef DISABLE_SYNC_TIMER
  112. uint32_t sync_timer;
  113. #endif // DISABLE_SYNC_TIMER
  114. #if !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
  115. split_layers_sync_t layers;
  116. #endif // !defined(NO_ACTION_LAYER) && defined(SPLIT_LAYER_STATE_ENABLE)
  117. #ifdef SPLIT_LED_STATE_ENABLE
  118. uint8_t led_state;
  119. #endif // SPLIT_LED_STATE_ENABLE
  120. #ifdef SPLIT_MODS_ENABLE
  121. split_mods_sync_t mods;
  122. #endif // SPLIT_MODS_ENABLE
  123. #ifdef BACKLIGHT_ENABLE
  124. uint8_t backlight_level;
  125. #endif // BACKLIGHT_ENABLE
  126. #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
  127. rgblight_syncinfo_t rgblight_sync;
  128. #endif // defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
  129. #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
  130. led_matrix_sync_t led_matrix_sync;
  131. #endif // defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
  132. #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
  133. rgb_matrix_sync_t rgb_matrix_sync;
  134. #endif // defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
  135. #if defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE)
  136. uint8_t current_wpm;
  137. #endif // defined(WPM_ENABLE) && defined(SPLIT_WPM_ENABLE)
  138. #if defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE)
  139. uint8_t current_oled_state;
  140. #endif // defined(OLED_ENABLE) && defined(SPLIT_OLED_ENABLE)
  141. #if defined(ST7565_ENABLE) && defined(SPLIT_ST7565_ENABLE)
  142. uint8_t current_st7565_state;
  143. #endif // ST7565_ENABLE(OLED_ENABLE) && defined(SPLIT_ST7565_ENABLE)
  144. #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
  145. rpc_sync_info_t rpc_info;
  146. uint8_t rpc_m2s_buffer[RPC_M2S_BUFFER_SIZE];
  147. uint8_t rpc_s2m_buffer[RPC_S2M_BUFFER_SIZE];
  148. #endif // defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER)
  149. } split_shared_memory_t;
  150. extern split_shared_memory_t *const split_shmem;