summaryrefslogtreecommitdiffstats
path: root/users/drashna/split
diff options
context:
space:
mode:
Diffstat (limited to 'users/drashna/split')
-rw-r--r--users/drashna/split/readme.md29
-rw-r--r--users/drashna/split/transport_sync.c57
-rw-r--r--users/drashna/split/transport_sync.h18
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 0000000000..5dad340122
--- /dev/null
+++ b/users/drashna/split/readme.md
@@ -0,0 +1,29 @@
+# Custom Split Transport
+
+To disable the customized split transport, add `CUSTOM_SPLIT_TRANSPORT_SYNC = no` to your `rules.mk`.
+
+This syncs a number of additional settings, such as the keymap_config (magic settings), user eeprom configs, and misc firmware settings.
+
+Additionally, this supports a watchdog timer reset for the secondary split side.
+
+## User State Config
+
+The User states that it sync are:
+
+* Audio Enable status
+* Audio Clicky states
+* Unicode mode
+* Pointing Device tap toggle status
+* Swap Hands status
+* Host Driver status
+
+## Userspace Config
+
+The userspace config states that are synced are:
+
+* RGB layer indication
+* "is overwatch" status
+* nuke switch
+* Swapped numbers
+* RGB Matrix idle animation
+* Autocorrect enable status
diff --git a/users/drashna/split/transport_sync.c b/users/drashna/split/transport_sync.c
index cee3f04c8f..794664293c 100644
--- a/users/drashna/split/transport_sync.c
+++ b/users/drashna/split/transport_sync.c
@@ -1,22 +1,12 @@
-/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+// Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+// SPDX-License-Identifier: GPL-2.0-or-later
#include "transport_sync.h"
#include "transactions.h"
#include <string.h>
+#ifdef __AVR__
+# include <avr/wdt.h>
+#endif
#ifdef CUSTOM_UNICODE_ENABLE
#include "process_unicode_common.h"
@@ -33,6 +23,10 @@ extern bool tap_toggling;
#ifdef SWAP_HANDS_ENABLE
extern bool swap_hands;
#endif
+
+static bool watchdog_ping_done = false;
+static uint32_t watchdog_timer = 0;
+
extern userspace_config_t userspace_config;
extern bool host_driver_disabled;
@@ -57,11 +51,20 @@ void user_config_sync(uint8_t initiator2target_buffer_size, const void* initiato
}
}
+void watchdog_handler(uint8_t in_buflen, const void* in_data, uint8_t out_buflen, void* out_data) { watchdog_ping_done = true; }
+
+
void keyboard_post_init_transport_sync(void) {
// Register keyboard state sync split transaction
transaction_register_rpc(RPC_ID_USER_STATE_SYNC, user_state_sync);
transaction_register_rpc(RPC_ID_USER_KEYMAP_SYNC, user_keymap_sync);
transaction_register_rpc(RPC_ID_USER_CONFIG_SYNC, user_config_sync);
+
+#ifdef __AVR__
+ wdt_disable();
+#endif
+ transaction_register_rpc(RPC_ID_USER_WATCHDOG_SYNC, watchdog_handler);
+ watchdog_timer = timer_read32();
}
void user_transport_update(void) {
@@ -163,6 +166,30 @@ void user_transport_sync(void) {
}
}
}
+
+ if (!watchdog_ping_done) {
+ if (is_keyboard_master()) {
+ if (timer_elapsed32(watchdog_timer) > 100) {
+ uint8_t any_data = 1;
+ if (transaction_rpc_send(RPC_ID_USER_WATCHDOG_SYNC, sizeof(any_data), &any_data)) {
+ watchdog_ping_done = true; // successful ping
+ } else {
+ dprint("Watchdog ping failed!\n");
+ }
+ watchdog_timer = timer_read32();
+ }
+ } else {
+ if (timer_elapsed32(watchdog_timer) > 3500) {
+#ifdef __AVR__
+ wdt_enable(WDTO_250MS);
+#else
+ NVIC_SystemReset();
+#endif
+ while (1) {
+ }
+ }
+ }
+ }
}
void housekeeping_task_user(void) {
diff --git a/users/drashna/split/transport_sync.h b/users/drashna/split/transport_sync.h
index 70b6ea522b..6b6f0c388b 100644
--- a/users/drashna/split/transport_sync.h
+++ b/users/drashna/split/transport_sync.h
@@ -1,19 +1,5 @@
-
-/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+// Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once