Implement split comms watchdog (#18599)
This commit is contained in:
parent
a9414f4840
commit
c255174cf3
10 changed files with 115 additions and 1 deletions
|
@ -74,6 +74,46 @@ static inline bool usbIsActive(void) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(SPLIT_WATCHDOG_ENABLE)
|
||||
# if !defined(SPLIT_WATCHDOG_TIMEOUT)
|
||||
# if defined(SPLIT_USB_TIMEOUT)
|
||||
# define SPLIT_WATCHDOG_TIMEOUT (SPLIT_USB_TIMEOUT + 100)
|
||||
# else
|
||||
# define SPLIT_WATCHDOG_TIMEOUT 3000
|
||||
# endif
|
||||
# endif
|
||||
# if defined(SPLIT_USB_DETECT)
|
||||
_Static_assert(SPLIT_USB_TIMEOUT < SPLIT_WATCHDOG_TIMEOUT, "SPLIT_WATCHDOG_TIMEOUT should not be below SPLIT_USB_TIMEOUT.");
|
||||
# endif
|
||||
_Static_assert(SPLIT_MAX_CONNECTION_ERRORS > 0, "SPLIT_WATCHDOG_ENABLE requires SPLIT_MAX_CONNECTION_ERRORS be above 0 for a functioning disconnection check.");
|
||||
|
||||
static uint32_t split_watchdog_started = 0;
|
||||
static bool split_watchdog_done = false;
|
||||
|
||||
void split_watchdog_init(void) {
|
||||
split_watchdog_started = timer_read32();
|
||||
}
|
||||
|
||||
void split_watchdog_update(bool done) {
|
||||
split_watchdog_done = done;
|
||||
}
|
||||
|
||||
bool split_watchdog_check(void) {
|
||||
if (!is_transport_connected()) {
|
||||
split_watchdog_done = false;
|
||||
}
|
||||
return split_watchdog_done;
|
||||
}
|
||||
|
||||
void split_watchdog_task(void) {
|
||||
if (!split_watchdog_done && !is_keyboard_master()) {
|
||||
if (timer_elapsed32(split_watchdog_started) > SPLIT_WATCHDOG_TIMEOUT) {
|
||||
mcu_reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // defined(SPLIT_WATCHDOG_ENABLE)
|
||||
|
||||
#ifdef SPLIT_HAND_MATRIX_GRID
|
||||
void matrix_io_delay(void);
|
||||
|
||||
|
@ -179,6 +219,9 @@ void split_pre_init(void) {
|
|||
void split_post_init(void) {
|
||||
if (!is_keyboard_master()) {
|
||||
transport_slave_init();
|
||||
#if defined(SPLIT_WATCHDOG_ENABLE)
|
||||
split_watchdog_init();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue