diff options
Diffstat (limited to 'quantum/split_common/split_util.c')
| -rw-r--r-- | quantum/split_common/split_util.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c index 35f0a9d181..7d50adf758 100644 --- a/quantum/split_common/split_util.c +++ b/quantum/split_common/split_util.c | |||
| @@ -43,14 +43,14 @@ | |||
| 43 | // Set to 0 to disable the disconnection check altogether. | 43 | // Set to 0 to disable the disconnection check altogether. |
| 44 | #ifndef SPLIT_MAX_CONNECTION_ERRORS | 44 | #ifndef SPLIT_MAX_CONNECTION_ERRORS |
| 45 | # define SPLIT_MAX_CONNECTION_ERRORS 10 | 45 | # define SPLIT_MAX_CONNECTION_ERRORS 10 |
| 46 | #endif // SPLIT_MAX_CONNECTION_ERRORS | 46 | #endif // SPLIT_MAX_CONNECTION_ERRORS |
| 47 | 47 | ||
| 48 | // How long (in milliseconds) to block all connection attempts after the communication has been flagged as disconnected. | 48 | // How long (in milliseconds) to block all connection attempts after the communication has been flagged as disconnected. |
| 49 | // One communication attempt will be allowed everytime this amount of time has passed since the last attempt. If that attempt succeeds, the communication is seen as working again. | 49 | // One communication attempt will be allowed everytime this amount of time has passed since the last attempt. If that attempt succeeds, the communication is seen as working again. |
| 50 | // Set to 0 to disable communication throttling while disconnected | 50 | // Set to 0 to disable communication throttling while disconnected |
| 51 | #ifndef SPLIT_CONNECTION_CHECK_TIMEOUT | 51 | #ifndef SPLIT_CONNECTION_CHECK_TIMEOUT |
| 52 | # define SPLIT_CONNECTION_CHECK_TIMEOUT 500 | 52 | # define SPLIT_CONNECTION_CHECK_TIMEOUT 500 |
| 53 | #endif // SPLIT_CONNECTION_CHECK_TIMEOUT | 53 | #endif // SPLIT_CONNECTION_CHECK_TIMEOUT |
| 54 | 54 | ||
| 55 | static uint8_t connection_errors = 0; | 55 | static uint8_t connection_errors = 0; |
| 56 | 56 | ||
| @@ -68,7 +68,9 @@ static bool usbIsActive(void) { | |||
| 68 | return false; | 68 | return false; |
| 69 | } | 69 | } |
| 70 | #else | 70 | #else |
| 71 | static inline bool usbIsActive(void) { return usb_vbus_state(); } | 71 | static inline bool usbIsActive(void) { |
| 72 | return usb_vbus_state(); | ||
| 73 | } | ||
| 72 | #endif | 74 | #endif |
| 73 | 75 | ||
| 74 | #ifdef SPLIT_HAND_MATRIX_GRID | 76 | #ifdef SPLIT_HAND_MATRIX_GRID |
| @@ -83,7 +85,7 @@ static uint8_t peek_matrix_intersection(pin_t out_pin, pin_t in_pin) { | |||
| 83 | uint8_t pin_state = readPin(in_pin); | 85 | uint8_t pin_state = readPin(in_pin); |
| 84 | // Set out_pin to a setting that is less susceptible to noise. | 86 | // Set out_pin to a setting that is less susceptible to noise. |
| 85 | setPinInputHigh(out_pin); | 87 | setPinInputHigh(out_pin); |
| 86 | matrix_io_delay(); // Wait for the pull-up to go HIGH. | 88 | matrix_io_delay(); // Wait for the pull-up to go HIGH. |
| 87 | return pin_state; | 89 | return pin_state; |
| 88 | } | 90 | } |
| 89 | #endif | 91 | #endif |
| @@ -158,7 +160,9 @@ void split_post_init(void) { | |||
| 158 | } | 160 | } |
| 159 | } | 161 | } |
| 160 | 162 | ||
| 161 | bool is_transport_connected(void) { return connection_errors < SPLIT_MAX_CONNECTION_ERRORS; } | 163 | bool is_transport_connected(void) { |
| 164 | return connection_errors < SPLIT_MAX_CONNECTION_ERRORS; | ||
| 165 | } | ||
| 162 | 166 | ||
| 163 | bool transport_master_if_connected(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { | 167 | bool transport_master_if_connected(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { |
| 164 | #if SPLIT_MAX_CONNECTION_ERRORS > 0 && SPLIT_CONNECTION_CHECK_TIMEOUT > 0 | 168 | #if SPLIT_MAX_CONNECTION_ERRORS > 0 && SPLIT_CONNECTION_CHECK_TIMEOUT > 0 |
| @@ -169,7 +173,7 @@ bool transport_master_if_connected(matrix_row_t master_matrix[], matrix_row_t sl | |||
| 169 | if (is_disconnected && timer_elapsed(connection_check_timer) < SPLIT_CONNECTION_CHECK_TIMEOUT) { | 173 | if (is_disconnected && timer_elapsed(connection_check_timer) < SPLIT_CONNECTION_CHECK_TIMEOUT) { |
| 170 | return false; | 174 | return false; |
| 171 | } | 175 | } |
| 172 | #endif // SPLIT_MAX_CONNECTION_ERRORS > 0 && SPLIT_CONNECTION_CHECK_TIMEOUT > 0 | 176 | #endif // SPLIT_MAX_CONNECTION_ERRORS > 0 && SPLIT_CONNECTION_CHECK_TIMEOUT > 0 |
| 173 | 177 | ||
| 174 | __attribute__((unused)) bool okay = transport_master(master_matrix, slave_matrix); | 178 | __attribute__((unused)) bool okay = transport_master(master_matrix, slave_matrix); |
| 175 | #if SPLIT_MAX_CONNECTION_ERRORS > 0 | 179 | #if SPLIT_MAX_CONNECTION_ERRORS > 0 |
| @@ -186,10 +190,10 @@ bool transport_master_if_connected(matrix_row_t master_matrix[], matrix_row_t sl | |||
| 186 | return connected; | 190 | return connected; |
| 187 | } else if (is_disconnected) { | 191 | } else if (is_disconnected) { |
| 188 | dprintln("Target connected"); | 192 | dprintln("Target connected"); |
| 189 | # endif // SPLIT_CONNECTION_CHECK_TIMEOUT > 0 | 193 | # endif // SPLIT_CONNECTION_CHECK_TIMEOUT > 0 |
| 190 | } | 194 | } |
| 191 | 195 | ||
| 192 | connection_errors = 0; | 196 | connection_errors = 0; |
| 193 | #endif // SPLIT_MAX_CONNECTION_ERRORS > 0 | 197 | #endif // SPLIT_MAX_CONNECTION_ERRORS > 0 |
| 194 | return true; | 198 | return true; |
| 195 | } | 199 | } |
