From 34c9f649252f173b9c046dcab56d86e0526ed163 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Tue, 28 Sep 2021 04:17:00 +1300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Sanity-check=20BLTOUCH=5FSET=5F5?= =?UTF-8?q?V=5FMODE=20on=205V=20pins=20(#22840)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/inc/SanityCheck.h | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 5408f25f38..58c02e7ebd 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1529,10 +1529,34 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #if ENABLED(BLTOUCH) + + // BLTouch can't run in 5V mode with a 3.3V probe pin + #if ENABLED(BLTOUCH_SET_5V_MODE) + #define _5V(P,A,B) WITHIN(P,A,B) + #ifdef STM32F1 // STM32F103 5V-tolerant pins + #define _IS_5V_TOLERANT(P) (_5V(P,PA8,PA15) || _5V(P,PB2,PB15) || _5V(P,PC6,PC12) || _5V(P,PD0,PD15) || _5V(P,PE0,PE15) || _5V(P,PF0,PF5) || _5V(P,PF11,PF15)) + #elif defined(ARDUINO_ARCH_SAM) + #define _IS_5V_TOLERANT(P) 0 // Assume no 5V tolerance + #else + #define _IS_5V_TOLERANT(P) 1 // Assume 5V tolerance + #endif + #if USES_Z_MIN_PROBE_PIN && !_IS_5V_TOLERANT(Z_MIN_PROBE_PIN) + #error "BLTOUCH_SET_5V_MODE is not compatible with the Z_MIN_PROBE_PIN." + #elif !_IS_5V_TOLERANT(Z_MIN_PIN) + #error "BLTOUCH_SET_5V_MODE is not compatible with the Z_MIN_PIN." + #endif + #undef _IS_5V_TOLERANT + #undef _5V + #elif NONE(ONBOARD_ENDSTOPPULLUPS, ENDSTOPPULLUPS, ENDSTOPPULLUP_ZMIN, ENDSTOPPULLUP_ZMIN_PROBE) + #if USES_Z_MIN_PROBE_PIN + #error "BLTOUCH on Z_MIN_PROBE_PIN requires ENDSTOPPULLUP_ZMIN_PROBE, ENDSTOPPULLUPS, or BLTOUCH_SET_5V_MODE." + #else + #error "BLTOUCH on Z_MIN_PIN requires ENDSTOPPULLUP_ZMIN, ENDSTOPPULLUPS, or BLTOUCH_SET_5V_MODE." + #endif + #endif + #if BLTOUCH_DELAY < 200 #error "BLTOUCH_DELAY less than 200 is unsafe and is not supported." - #elif DISABLED(BLTOUCH_SET_5V_MODE) && NONE(ONBOARD_ENDSTOPPULLUPS, ENDSTOPPULLUPS, ENDSTOPPULLUP_ZMIN, ENDSTOPPULLUP_ZMIN_PROBE) - #error "BLTOUCH without BLTOUCH_SET_5V_MODE requires ENDSTOPPULLUPS, ENDSTOPPULLUP_ZMIN or ENDSTOPPULLUP_ZMIN_PROBE." #endif #endif