diff --git a/firmware/hw_layer/debounce.cpp b/firmware/hw_layer/debounce.cpp index 903489d1f1..faed5cab94 100644 --- a/firmware/hw_layer/debounce.cpp +++ b/firmware/hw_layer/debounce.cpp @@ -56,13 +56,17 @@ void ButtonDebounce::stopConfiguration () { #endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */ #ifndef EFI_UNIT_TEST brain_pin_markUnused(active_pin); + needsInit = true; #endif /* EFI_UNIT_TEST */ } } void ButtonDebounce::startConfiguration () { #ifndef EFI_UNIT_TEST - efiSetPadMode("Button", *m_pin, getInputMode(*m_mode)); + if (needsInit) { + efiSetPadMode("Button", *m_pin, getInputMode(*m_mode)); + needsInit = false; + } #endif active_pin = *m_pin; active_mode = *m_mode; @@ -77,7 +81,7 @@ bool ButtonDebounce::readPinEvent() { } bool ButtonDebounce::readPinState() { - if (!m_pin) { + if (*m_pin == GPIO_UNASSIGNED) { return false; } efitick_t timeNow = getTimeNowNt(); diff --git a/firmware/hw_layer/debounce.h b/firmware/hw_layer/debounce.h index f9225513d9..dc6adaed31 100644 --- a/firmware/hw_layer/debounce.h +++ b/firmware/hw_layer/debounce.h @@ -33,4 +33,5 @@ private: bool initialized = false; ButtonDebounce *nextDebounce = nullptr; static ButtonDebounce* s_firstDebounce; + bool needsInit = false; };