From 6920b7fe910ce230368d395419c99f4bd53c02a0 Mon Sep 17 00:00:00 2001
From: Msq001 <760675063@qq.com>
Date: Thu, 18 Jul 2019 18:43:49 +0800
Subject: [PATCH] BigTreeTech SKR E3 DIP (#14638)

---
 Marlin/src/core/boards.h                      |   9 +-
 Marlin/src/pins/pins.h                        |   2 +
 .../src/pins/stm32/pins_BIGTREE_SKR_E3_DIP.h  | 183 ++++++++++++++++++
 platformio.ini                                |   2 +-
 4 files changed, 191 insertions(+), 5 deletions(-)
 create mode 100644 Marlin/src/pins/stm32/pins_BIGTREE_SKR_E3_DIP.h

diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h
index abc232d0704..cffb2c8dd51 100644
--- a/Marlin/src/core/boards.h
+++ b/Marlin/src/core/boards.h
@@ -261,10 +261,11 @@
 #define BOARD_MKS_ROBIN_NANO          4007  // MKS Robin Nano (STM32F103VET6)
 #define BOARD_BIGTREE_SKR_MINI_V1_1   4008  // BigTreeTech SKR Mini v1.1 (STM32F103RC)
 #define BOARD_BIGTREE_SKR_MINI_E3     4009  // BigTreeTech SKR Mini E3 (STM32F103RC)
-#define BOARD_JGAURORA_A5S_A1         4010  // JGAurora A5S A1 (STM32F103ZET6)
-#define BOARD_FYSETC_AIO_II           4011  // FYSETC AIO_II
-#define BOARD_FYSETC_CHEETAH          4012  // FYSETC CHEETAH
-#define BOARD_LONGER3D_LK             4013  // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VET6
+#define BOARD_BIGTREE_SKR_E3_DIP      4010  // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC)
+#define BOARD_JGAURORA_A5S_A1         4011  // JGAurora A5S A1 (STM32F103ZET6)
+#define BOARD_FYSETC_AIO_II           4012  // FYSETC AIO_II
+#define BOARD_FYSETC_CHEETAH          4013  // FYSETC Cheetah
+#define BOARD_LONGER3D_LK             4014  // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VET6
 
 //
 // ARM Cortex-M4F
diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h
index 0f7c0be4ac3..e838dbd4ac4 100644
--- a/Marlin/src/pins/pins.h
+++ b/Marlin/src/pins/pins.h
@@ -444,6 +444,8 @@
   #include "stm32/pins_BIGTREE_SKR_MINI_V1_1.h" // STM32F1                                env:BIGTREE_SKR_MINI
 #elif MB(BIGTREE_SKR_MINI_E3)
   #include "stm32/pins_BIGTREE_SKR_MINI_E3.h"   // STM32F1                                env:BIGTREE_SKR_MINI
+#elif MB(BIGTREE_SKR_E3_DIP)
+  #include "stm32/pins_BIGTREE_SKR_E3_DIP.h"    // STM32F1                                env:BIGTREE_SKR_MINI
 #elif MB(MALYAN_M200)
   #include "stm32/pins_MALYAN_M200.h"           // STM32F1                                env:malyanm200
 #elif MB(CHITU3D)
diff --git a/Marlin/src/pins/stm32/pins_BIGTREE_SKR_E3_DIP.h b/Marlin/src/pins/stm32/pins_BIGTREE_SKR_E3_DIP.h
new file mode 100644
index 00000000000..40346c6a625
--- /dev/null
+++ b/Marlin/src/pins/stm32/pins_BIGTREE_SKR_E3_DIP.h
@@ -0,0 +1,183 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+#pragma once
+
+#ifndef TARGET_STM32F1
+  #error "Oops! Select an STM32F1 board in 'Tools > Board.'"
+#endif
+
+#define BOARD_NAME "BIGTREE SKR E3 DIP V1.0"
+
+// Release PB3/PB4 (TMC_SW Pins) from JTAG pins
+#define DISABLE_JTAG
+
+// Ignore temp readings during development.
+//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000
+
+//
+// Servos
+//
+#define SERVO0_PIN         PA1
+
+//
+// Limit Switches
+//
+#define X_STOP_PIN         PC1
+#define Y_STOP_PIN         PC0
+#define Z_STOP_PIN         PC15
+
+//
+// Z Probe must be this pin
+//
+#define Z_MIN_PROBE_PIN    PC14
+
+//
+// Filament Runout Sensor
+//
+#ifndef FIL_RUNOUT_PIN
+  #define FIL_RUNOUT_PIN   PC2
+#endif
+
+//
+// Steppers
+//
+#define X_ENABLE_PIN       PC7
+#define X_STEP_PIN         PC6
+#define X_DIR_PIN          PB15
+#ifndef X_CS_PIN
+  #define X_CS_PIN         PC10
+#endif
+
+#define Y_ENABLE_PIN       PB14
+#define Y_STEP_PIN         PB13
+#define Y_DIR_PIN          PB12
+#ifndef Y_CS_PIN
+  #define Y_CS_PIN         PC11
+#endif
+
+#define Z_ENABLE_PIN       PB11
+#define Z_STEP_PIN         PB10
+#define Z_DIR_PIN          PB2
+#ifndef Z_CS_PIN
+  #define Z_CS_PIN         PC12
+#endif
+
+#define E0_ENABLE_PIN      PB1
+#define E0_STEP_PIN        PB0
+#define E0_DIR_PIN         PC5  
+#ifndef E0_CS_PIN
+  #define E0_CS_PIN        PD2
+#endif
+
+//
+// Software SPI pins for TMC2130 stepper drivers
+//
+#if ENABLED(TMC_USE_SW_SPI)
+  #ifndef TMC_SW_MOSI
+    #define TMC_SW_MOSI    PB5
+  #endif
+  #ifndef TMC_SW_MISO
+    #define TMC_SW_MISO    PB4
+  #endif
+  #ifndef TMC_SW_SCK
+    #define TMC_SW_SCK     PB3
+  #endif
+#endif
+
+#if HAS_TMC220x
+  /**
+   * TMC2208/TMC2209 stepper drivers
+   *
+   * Hardware serial communication ports.
+   * If undefined software serial is used according to the pins below
+   */
+  //#define X_HARDWARE_SERIAL  Serial1
+  //#define Y_HARDWARE_SERIAL  Serial1
+  //#define Z_HARDWARE_SERIAL  Serial1
+  //#define E0_HARDWARE_SERIAL Serial1
+
+  //
+  // Software serial
+  //
+  #define X_SERIAL_TX_PIN  PC10
+  #define X_SERIAL_RX_PIN  PC10
+
+  #define Y_SERIAL_TX_PIN  PC11
+  #define Y_SERIAL_RX_PIN  PC11
+
+  #define Z_SERIAL_TX_PIN  PC12
+  #define Z_SERIAL_RX_PIN  PC12
+
+  #define E0_SERIAL_TX_PIN PD2
+  #define E0_SERIAL_RX_PIN PD2
+
+#endif
+
+//
+// Temperature Sensors
+//
+#define TEMP_0_PIN         PA0   // Analog Input
+#define TEMP_BED_PIN       PC3   // Analog Input
+
+//
+// Heaters / Fans
+//
+#define HEATER_0_PIN       PC8   // EXTRUDER
+#define HEATER_BED_PIN     PC9   // BED
+#define FAN_PIN            PA8
+
+//
+// USB connect control
+//
+#define USB_CONNECT        PC13
+#define USB_CONNECT_INVERTING false
+
+#define SD_DETECT_PIN      PC4
+
+/**
+ *                 _____
+ *             5V | · · | GND
+ *  (LCD_EN) PB7  | · · | PB8  (LCD_RS)
+ *  (LCD_D4) PB9  | · · | PA10 (BTN_EN2)
+ *          RESET | · · | PA9  (BTN_EN1)
+ * (BTN_ENC) PB6  | · · | PA15 (BEEPER)
+ *                 -----
+ *                 EXP1
+ */
+#if HAS_SPI_LCD
+  #define BEEPER_PIN       PA15
+  #define BTN_ENC          PB6
+
+  #if ENABLED(CR10_STOCKDISPLAY)
+    #define LCD_PINS_RS    PB8
+
+    #define BTN_EN1        PA9
+    #define BTN_EN2        PA10
+
+    #define LCD_PINS_ENABLE PB7
+    #define LCD_PINS_D4    PB9
+
+  #else
+    #error "Only CR10_STOCKDISPLAY is currently supported on the BIGTREE_SKR_E3_DIP."
+  #endif
+
+#endif // HAS_SPI_LCD
diff --git a/platformio.ini b/platformio.ini
index 84a4a677524..b7a5e335fd1 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -303,7 +303,7 @@ debug_tool    = stlink
 upload_protocol = serial
 
 #
-# BIGTREE_SKR_MINI
+# BigTree SKR Mini V1.1 / SKR mini E3 / SKR E3 DIP (STM32F103RCT6 ARM Cortex-M3)
 #
 [env:BIGTREE_SKR_MINI]
 platform      = ststm32