diff options
| author | Drashna Jaelre <drashna@live.com> | 2021-12-29 20:17:34 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-29 20:17:34 -0800 |
| commit | c4551d7ef1ed2c1069f23cc8499b7c7fc30f3ecf (patch) | |
| tree | 67dc381a45d59626132c4c59b71c4b36fa971f8b /users/drashna/split | |
| parent | 1a8a842cfb3e87a82afb57ba29ca59c5fa6fe97b (diff) | |
| download | qmk_firmware-c4551d7ef1ed2c1069f23cc8499b7c7fc30f3ecf.tar.gz qmk_firmware-c4551d7ef1ed2c1069f23cc8499b7c7fc30f3ecf.zip | |
[Keymap] Reorganization, cleanup and readmes for drashna code (#15617)
Diffstat (limited to 'users/drashna/split')
| -rw-r--r-- | users/drashna/split/readme.md | 29 | ||||
| -rw-r--r-- | users/drashna/split/transport_sync.c | 57 | ||||
| -rw-r--r-- | users/drashna/split/transport_sync.h | 18 |
3 files changed, 73 insertions, 31 deletions
diff --git a/users/drashna/split/readme.md b/users/drashna/split/readme.md new file mode 100644 index 000000000..5dad34012 --- /dev/null +++ b/users/drashna/split/readme.md | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | # Custom Split Transport | ||
| 2 | |||
| 3 | To disable the customized split transport, add `CUSTOM_SPLIT_TRANSPORT_SYNC = no` to your `rules.mk`. | ||
| 4 | |||
| 5 | This syncs a number of additional settings, such as the keymap_config (magic settings), user eeprom configs, and misc firmware settings. | ||
| 6 | |||
| 7 | Additionally, this supports a watchdog timer reset for the secondary split side. | ||
| 8 | |||
| 9 | ## User State Config | ||
| 10 | |||
| 11 | The User states that it sync are: | ||
| 12 | |||
| 13 | * Audio Enable status | ||
| 14 | * Audio Clicky states | ||
| 15 | * Unicode mode | ||
| 16 | * Pointing Device tap toggle status | ||
| 17 | * Swap Hands status | ||
| 18 | * Host Driver status | ||
| 19 | |||
| 20 | ## Userspace Config | ||
| 21 | |||
| 22 | The userspace config states that are synced are: | ||
| 23 | |||
| 24 | * RGB layer indication | ||
| 25 | * "is overwatch" status | ||
| 26 | * nuke switch | ||
| 27 | * Swapped numbers | ||
| 28 | * RGB Matrix idle animation | ||
| 29 | * Autocorrect enable status | ||
diff --git a/users/drashna/split/transport_sync.c b/users/drashna/split/transport_sync.c index cee3f04c8..794664293 100644 --- a/users/drashna/split/transport_sync.c +++ b/users/drashna/split/transport_sync.c | |||
| @@ -1,22 +1,12 @@ | |||
| 1 | /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> | 1 | // Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> |
| 2 | * | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 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 | 3 | ||
| 17 | #include "transport_sync.h" | 4 | #include "transport_sync.h" |
| 18 | #include "transactions.h" | 5 | #include "transactions.h" |
| 19 | #include <string.h> | 6 | #include <string.h> |
| 7 | #ifdef __AVR__ | ||
| 8 | # include <avr/wdt.h> | ||
| 9 | #endif | ||
| 20 | 10 | ||
| 21 | #ifdef CUSTOM_UNICODE_ENABLE | 11 | #ifdef CUSTOM_UNICODE_ENABLE |
| 22 | #include "process_unicode_common.h" | 12 | #include "process_unicode_common.h" |
| @@ -33,6 +23,10 @@ extern bool tap_toggling; | |||
| 33 | #ifdef SWAP_HANDS_ENABLE | 23 | #ifdef SWAP_HANDS_ENABLE |
| 34 | extern bool swap_hands; | 24 | extern bool swap_hands; |
| 35 | #endif | 25 | #endif |
| 26 | |||
| 27 | static bool watchdog_ping_done = false; | ||
| 28 | static uint32_t watchdog_timer = 0; | ||
| 29 | |||
| 36 | extern userspace_config_t userspace_config; | 30 | extern userspace_config_t userspace_config; |
| 37 | extern bool host_driver_disabled; | 31 | extern bool host_driver_disabled; |
| 38 | 32 | ||
| @@ -57,11 +51,20 @@ void user_config_sync(uint8_t initiator2target_buffer_size, const void* initiato | |||
| 57 | } | 51 | } |
| 58 | } | 52 | } |
| 59 | 53 | ||
| 54 | void watchdog_handler(uint8_t in_buflen, const void* in_data, uint8_t out_buflen, void* out_data) { watchdog_ping_done = true; } | ||
| 55 | |||
| 56 | |||
| 60 | void keyboard_post_init_transport_sync(void) { | 57 | void keyboard_post_init_transport_sync(void) { |
| 61 | // Register keyboard state sync split transaction | 58 | // Register keyboard state sync split transaction |
| 62 | transaction_register_rpc(RPC_ID_USER_STATE_SYNC, user_state_sync); | 59 | transaction_register_rpc(RPC_ID_USER_STATE_SYNC, user_state_sync); |
| 63 | transaction_register_rpc(RPC_ID_USER_KEYMAP_SYNC, user_keymap_sync); | 60 | transaction_register_rpc(RPC_ID_USER_KEYMAP_SYNC, user_keymap_sync); |
| 64 | transaction_register_rpc(RPC_ID_USER_CONFIG_SYNC, user_config_sync); | 61 | transaction_register_rpc(RPC_ID_USER_CONFIG_SYNC, user_config_sync); |
| 62 | |||
| 63 | #ifdef __AVR__ | ||
| 64 | wdt_disable(); | ||
| 65 | #endif | ||
| 66 | transaction_register_rpc(RPC_ID_USER_WATCHDOG_SYNC, watchdog_handler); | ||
| 67 | watchdog_timer = timer_read32(); | ||
| 65 | } | 68 | } |
| 66 | 69 | ||
| 67 | void user_transport_update(void) { | 70 | void user_transport_update(void) { |
| @@ -163,6 +166,30 @@ void user_transport_sync(void) { | |||
| 163 | } | 166 | } |
| 164 | } | 167 | } |
| 165 | } | 168 | } |
| 169 | |||
| 170 | if (!watchdog_ping_done) { | ||
| 171 | if (is_keyboard_master()) { | ||
| 172 | if (timer_elapsed32(watchdog_timer) > 100) { | ||
| 173 | uint8_t any_data = 1; | ||
| 174 | if (transaction_rpc_send(RPC_ID_USER_WATCHDOG_SYNC, sizeof(any_data), &any_data)) { | ||
| 175 | watchdog_ping_done = true; // successful ping | ||
| 176 | } else { | ||
| 177 | dprint("Watchdog ping failed!\n"); | ||
| 178 | } | ||
| 179 | watchdog_timer = timer_read32(); | ||
| 180 | } | ||
| 181 | } else { | ||
| 182 | if (timer_elapsed32(watchdog_timer) > 3500) { | ||
| 183 | #ifdef __AVR__ | ||
| 184 | wdt_enable(WDTO_250MS); | ||
| 185 | #else | ||
| 186 | NVIC_SystemReset(); | ||
| 187 | #endif | ||
| 188 | while (1) { | ||
| 189 | } | ||
| 190 | } | ||
| 191 | } | ||
| 192 | } | ||
| 166 | } | 193 | } |
| 167 | 194 | ||
| 168 | void housekeeping_task_user(void) { | 195 | void housekeeping_task_user(void) { |
diff --git a/users/drashna/split/transport_sync.h b/users/drashna/split/transport_sync.h index 70b6ea522..6b6f0c388 100644 --- a/users/drashna/split/transport_sync.h +++ b/users/drashna/split/transport_sync.h | |||
| @@ -1,19 +1,5 @@ | |||
| 1 | 1 | // Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> | |
| 2 | /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | * | ||
| 4 | * This program is free software: you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation, either version 2 of the License, or | ||
| 7 | * (at your option) any later version. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | 3 | ||
| 18 | #pragma once | 4 | #pragma once |
| 19 | 5 | ||
