From 4ba4ab1c75bbf87c33b94bbb18b6cae4897fc226 Mon Sep 17 00:00:00 2001
From: ellensp <530024+ellensp@users.noreply.github.com>
Date: Tue, 22 Feb 2022 13:31:44 +1300
Subject: [PATCH] =?UTF-8?q?=F0=9F=93=8C=20Creality=20RAMPS=20optional=20SD?=
 =?UTF-8?q?=5FDETECT=5FPIN=20(#23740)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
---
 Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h b/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h
index 21dadd60eeb..679503e9826 100644
--- a/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h
+++ b/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h
@@ -39,7 +39,12 @@
 #endif
 
 #ifndef SD_DETECT_PIN
-  #define SD_DETECT_PIN                       49  // Always define onboard SD detect
+  #if SD_CONNECTION_IS(ONBOARD)
+    //#define HAS_ONBOARD_SD_DETECT               // If the SD_DETECT_PIN is wired up
+  #endif
+  #if ENABLED(HAS_ONBOARD_SD_DETECT) || !SD_CONNECTION_IS(ONBOARD)
+    #define SD_DETECT_PIN                     49
+  #endif
 #endif
 
 #ifndef PS_ON_PIN