From 42fb7c14b09b6e484334f0a39f1e1ae3d6fa5381 Mon Sep 17 00:00:00 2001
From: Christopher Pepper <p3p@p3psoft.co.uk>
Date: Sat, 13 Oct 2018 19:58:49 +0100
Subject: [PATCH] Update the sdcard usb sharing config and apply to Re-ARM

---
 Marlin/src/pins/pins_MKS_SBASE.h    | 15 +++++++--------
 Marlin/src/pins/pins_RAMPS_RE_ARM.h | 30 ++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/Marlin/src/pins/pins_MKS_SBASE.h b/Marlin/src/pins/pins_MKS_SBASE.h
index be84367e42..a901573c0f 100644
--- a/Marlin/src/pins/pins_MKS_SBASE.h
+++ b/Marlin/src/pins/pins_MKS_SBASE.h
@@ -189,7 +189,7 @@
  * definitions control this feature:
  */
 //#define USB_SD_DISABLED
-#define USB_SD_ONBOARD
+#define USB_SD_ONBOARD        // Provide the onboard SD card to the host as a USB mass storage device
 
 /*
  * There are a number of configurations available for the SBase SD card reader.
@@ -198,11 +198,11 @@
  * The onboard SD card can be used and optionally shared with a PC via USB.
  */
 
-//#define SBASE_SD_CUSTOM_CABLE // Use a custom cable to access the SD
-//#define SBASE_SD_LCD          // Use the SD drive attached to the LCD
-#define SBASE_SD_ONBOARD        // Use the SD drive on the control board
+//#define LPC_SD_CUSTOM_CABLE // Use a custom cable to access the SD
+//#define LPC_SD_LCD          // Marlin uses the SD drive attached to the LCD
+#define LPC_SD_ONBOARD        // Marlin uses the SD drive attached to the control board
 
-#ifdef SBASE_SD_CUSTOM_CABLE
+#ifdef LPC_SD_CUSTOM_CABLE
   /**
    * A custom cable is needed. See the README file in the
    * Marlin\src\config\examples\Mks\Sbase directory
@@ -225,11 +225,10 @@
                             // selected pins are not on a hardware SPI controller
 #endif
 
-#ifdef SBASE_SD_LCD
+#ifdef LPC_SD_LCD
   // use standard cable and header, SPI and SD detect sre shared with on-board SD card
   // hardware SPI is used for both SD cards. The detect pin is shred between the
   // LCD and onboard SD readers so we disable it.
-  #define SD_DETECT_PIN      P0_27
   #undef SD_DETECT_PIN
   #define SCK_PIN            P0_07
   #define MISO_PIN           P0_08
@@ -238,7 +237,7 @@
   #define ONBOARD_SD_CS      P0_06   // Chip select for "System" SD card
 #endif
 
-#ifdef SBASE_SD_ONBOARD
+#ifdef LPC_SD_ONBOARD
   // The external SD card is not used. Hardware SPI is used to access the card.
   #ifdef USB_SD_ONBOARD
     // When sharing the SD card with a PC we want the menu options to
diff --git a/Marlin/src/pins/pins_RAMPS_RE_ARM.h b/Marlin/src/pins/pins_RAMPS_RE_ARM.h
index 6f0c604ffb..534144c298 100644
--- a/Marlin/src/pins/pins_RAMPS_RE_ARM.h
+++ b/Marlin/src/pins/pins_RAMPS_RE_ARM.h
@@ -198,7 +198,6 @@
 // Misc. Functions
 //
 #define LED_PIN           P4_28   // (13)
-#define SDSS              P1_23   // (53)
 
 // define digital pin 4 for the filament runout sensor. Use the RAMPS 1.4 digital input 4 on the servos connector
 #ifndef FIL_RUNOUT_PIN
@@ -364,6 +363,35 @@
 #define ENET_TXD0     P1_00   // (78)  J12-11
 #define ENET_TXD1     P1_01   // (79)  J12-12
 
+
+//#define USB_SD_DISABLED
+#define USB_SD_ONBOARD        // Provide the onboard SD card to the host as a USB mass storage device
+
+//#define LPC_SD_LCD          // Marlin uses the SD drive attached to the LCD
+#define LPC_SD_ONBOARD        // Marlin uses the SD drive on the control board
+
+#ifdef LPC_SD_LCD
+  #define SCK_PIN            P0_15
+  #define MISO_PIN           P0_17
+  #define MOSI_PIN           P0_18
+  #define SS_PIN             P1_23   // Chip select for SD card used by Marlin
+  #define ONBOARD_SD_CS      P0_06   // Chip select for "System" SD card
+#endif
+
+#ifdef LPC_SD_ONBOARD
+  #ifdef USB_SD_ONBOARD
+    // When sharing the SD card with a PC we want the menu options to
+    // mount/unmount the card and refresh it. So we disable card detect.
+    #define SHARED_SD_CARD
+    #undef SD_DETECT_PIN // there is also no detect pin for the onboard card
+  #endif
+  #define SCK_PIN            P0_07
+  #define MISO_PIN           P0_08
+  #define MOSI_PIN           P0_09
+  #define SS_PIN             P0_06   // Chip select for SD card used by Marlin
+  #define ONBOARD_SD_CS      P0_06   // Chip select for "System" SD card
+#endif
+
 /**
  *  Fast PWMS
  *