From ceeba58dc9688f7d92a77cc32468db9d8ad69f56 Mon Sep 17 00:00:00 2001
From: George Fu <nailao_5918@163.com>
Date: Sat, 4 Jan 2020 10:29:25 +0800
Subject: [PATCH] FYSETC F6 v1.4 board support (#16321)

---
 Marlin/src/core/boards.h                  | 23 ++++-----
 Marlin/src/pins/pins.h                    |  3 +-
 Marlin/src/pins/ramps/pins_FYSETC_F6_13.h | 58 +++++++++++++++++------
 Marlin/src/pins/ramps/pins_FYSETC_F6_14.h | 50 +++++++++++++++++++
 platformio.ini                            | 11 +++++
 5 files changed, 118 insertions(+), 27 deletions(-)
 create mode 100644 Marlin/src/pins/ramps/pins_FYSETC_F6_14.h

diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h
index 4367e5ed46..bd7c98081e 100644
--- a/Marlin/src/core/boards.h
+++ b/Marlin/src/core/boards.h
@@ -90,17 +90,18 @@
 #define BOARD_RAMPS_ENDER_4           1134  // Creality: Ender-4, CR-8
 #define BOARD_RAMPS_CREALITY          1135  // Creality: CR10S, CR20, CR-X
 #define BOARD_RAMPS_DAGOMA            1136  // Dagoma F5
-#define BOARD_FYSETC_F6_13            1137  // FYSETC F6
-#define BOARD_DUPLICATOR_I3_PLUS      1138  // Wanhao Duplicator i3 Plus
-#define BOARD_VORON                   1139  // VORON Design
-#define BOARD_TRONXY_V3_1_0           1140  // Tronxy TRONXY-V3-1.0
-#define BOARD_Z_BOLT_X_SERIES         1141  // Z-Bolt X Series
-#define BOARD_TT_OSCAR                1142  // TT OSCAR
-#define BOARD_OVERLORD                1143  // Overlord/Overlord Pro
-#define BOARD_HJC2560C_REV1           1144  // ADIMLab Gantry v1
-#define BOARD_HJC2560C_REV2           1145  // ADIMLab Gantry v2
-#define BOARD_TANGO                   1146  // BIQU Tango V1
-#define BOARD_MKS_GEN_L_V2            1147  // MKS GEN L V2
+#define BOARD_FYSETC_F6_13            1137  // FYSETC F6 1.3
+#define BOARD_FYSETC_F6_14            1138  // FYSETC F6 1.4
+#define BOARD_DUPLICATOR_I3_PLUS      1139  // Wanhao Duplicator i3 Plus
+#define BOARD_VORON                   1140  // VORON Design
+#define BOARD_TRONXY_V3_1_0           1141  // Tronxy TRONXY-V3-1.0
+#define BOARD_Z_BOLT_X_SERIES         1142  // Z-Bolt X Series
+#define BOARD_TT_OSCAR                1143  // TT OSCAR
+#define BOARD_OVERLORD                1144  // Overlord/Overlord Pro
+#define BOARD_HJC2560C_REV1           1145  // ADIMLab Gantry v1
+#define BOARD_HJC2560C_REV2           1146  // ADIMLab Gantry v2
+#define BOARD_TANGO                   1147  // BIQU Tango V1
+#define BOARD_MKS_GEN_L_V2            1148  // MKS GEN L V2
 
 //
 // RAMBo and derivatives
diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h
index 9dcbce87f6..856f6055da 100644
--- a/Marlin/src/pins/pins.h
+++ b/Marlin/src/pins/pins.h
@@ -170,6 +170,8 @@
   #include "ramps/pins_RAMPS_DAGOMA.h"          // ATmega2560                             env:megaatmega2560
 #elif MB(FYSETC_F6_13)
   #include "ramps/pins_FYSETC_F6_13.h"          // ATmega2560                             env:FYSETC_F6_13
+#elif MB(FYSETC_F6_14)
+  #include "ramps/pins_FYSETC_F6_14.h"          // ATmega2560                             env:FYSETC_F6_14
 #elif MB(DUPLICATOR_I3_PLUS)
   #include "ramps/pins_DUPLICATOR_I3_PLUS.h"    // ATmega2560                             env:megaatmega2560
 #elif MB(VORON)
@@ -185,7 +187,6 @@
 #elif MB(MKS_GEN_L_V2)
   #include "ramps/pins_MKS_GEN_L_V2.h"          // ATmega2560                             env:megaatmega2560
 
-
 //
 // RAMBo and derivatives
 //
diff --git a/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h b/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h
index 1168948d93..4c6f59aaae 100644
--- a/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h
+++ b/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h
@@ -22,7 +22,7 @@
 #pragma once
 
 //
-// FYSETC F6 pin assignments
+// FYSETC F6 1.3 (and 1.4) pin assignments
 //
 
 #ifndef __AVR_ATmega2560__
@@ -33,7 +33,9 @@
   //#error "SD_DETECT_INVERTED must be disabled for the FYSETC_F6_13 board."
 #endif
 
-#define BOARD_INFO_NAME "FYSETC F6 1.3"
+#ifndef BOARD_INFO_NAME
+  #define BOARD_INFO_NAME "FYSETC F6 1.3"
+#endif
 
 #define RESET_PIN          30
 #define SPI_FLASH_CS       83
@@ -54,7 +56,9 @@
 #define Y_MIN_PIN          14
 #define Y_MAX_PIN          15
 #define Z_MIN_PIN          12
-#define Z_MAX_PIN           9
+#ifndef Z_MAX_PIN
+  #define Z_MAX_PIN         9
+#endif
 
 #ifndef FIL_RUNOUT_PIN
   #define FIL_RUNOUT_PIN   SERVO2_PIN
@@ -124,18 +128,42 @@
    * Software serial communication pins.
    * At the moment, F6 rx pins are not pc interrupt pins
    */
-  #define X_SERIAL_RX_PIN  -1   // 71
-  #define X_SERIAL_TX_PIN  72
-  #define Y_SERIAL_RX_PIN  -1   // 73
-  #define Y_SERIAL_TX_PIN  75
-  #define Z_SERIAL_RX_PIN  -1   // 78
-  #define Z_SERIAL_TX_PIN  79
-  #define E0_SERIAL_RX_PIN -1   // 76
-  #define E0_SERIAL_TX_PIN 77
-  #define E1_SERIAL_RX_PIN -1   // 80
-  #define E1_SERIAL_TX_PIN 81
-  #define E2_SERIAL_RX_PIN -1   // 22
-  #define E2_SERIAL_TX_PIN 82
+  #ifndef X_SERIAL_RX_PIN
+    #define X_SERIAL_RX_PIN  -1   // 71
+  #endif
+  #ifndef X_SERIAL_TX_PIN
+    #define X_SERIAL_TX_PIN  72
+  #endif
+  #ifndef Y_SERIAL_RX_PIN
+    #define Y_SERIAL_RX_PIN  -1   // 73
+  #endif
+  #ifndef Y_SERIAL_TX_PIN
+    #define Y_SERIAL_TX_PIN  75
+  #endif
+  #ifndef Z_SERIAL_RX_PIN
+    #define Z_SERIAL_RX_PIN  -1   // 78
+  #endif
+  #ifndef Z_SERIAL_TX_PIN
+    #define Z_SERIAL_TX_PIN  79
+  #endif
+  #ifndef E0_SERIAL_RX_PIN
+    #define E0_SERIAL_RX_PIN -1   // 76
+  #endif
+  #ifndef E0_SERIAL_TX_PIN
+    #define E0_SERIAL_TX_PIN 77
+  #endif
+  #ifndef E1_SERIAL_RX_PIN
+    #define E1_SERIAL_RX_PIN -1   // 80
+  #endif
+  #ifndef E1_SERIAL_TX_PIN
+    #define E1_SERIAL_TX_PIN 81
+  #endif
+  #ifndef E2_SERIAL_RX_PIN
+    #define E2_SERIAL_RX_PIN -1   // 22
+  #endif
+  #ifndef E2_SERIAL_TX_PIN
+    #define E2_SERIAL_TX_PIN 82
+  #endif
 #endif
 
 //
diff --git a/Marlin/src/pins/ramps/pins_FYSETC_F6_14.h b/Marlin/src/pins/ramps/pins_FYSETC_F6_14.h
new file mode 100644
index 0000000000..088955ff0c
--- /dev/null
+++ b/Marlin/src/pins/ramps/pins_FYSETC_F6_14.h
@@ -0,0 +1,50 @@
+/**
+ * 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
+
+//
+// FYSETC F6 v1.4 pin assignments
+//
+
+#define BOARD_NAME "FYSETC F6 1.4"
+
+#define Z_MAX_PIN           2
+
+#if HAS_TMC220x
+  /**
+   * TMC2208/TMC2209 stepper drivers
+   */
+  #define X_SERIAL_RX_PIN  72
+  #define X_SERIAL_TX_PIN  71
+  #define Y_SERIAL_RX_PIN  73
+  #define Y_SERIAL_TX_PIN  78
+  #define Z_SERIAL_RX_PIN  75
+  #define Z_SERIAL_TX_PIN  79
+  #define E0_SERIAL_RX_PIN 77
+  #define E0_SERIAL_TX_PIN 81
+  #define E1_SERIAL_RX_PIN 76
+  #define E1_SERIAL_TX_PIN 80
+  #define E2_SERIAL_RX_PIN 62
+  #define E2_SERIAL_TX_PIN 82
+#endif
+
+#include "pins_FYSETC_F6_13.h"
diff --git a/platformio.ini b/platformio.ini
index ba4dc4dfc0..420c002298 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -98,6 +98,17 @@ lib_deps          = ${common.lib_deps}
   TMC26XStepper=https://github.com/trinamic/TMC26XStepper/archive/master.zip
 src_filter        = ${common.default_src_filter} +<src/HAL/HAL_AVR>
 
+#
+# FYSETC F6 V1.4
+#
+[env:FYSETC_F6_14]
+platform          = atmelavr
+board             = fysetc_f6_14
+board_build.f_cpu = 16000000L
+lib_deps          = ${common.lib_deps}
+  TMC26XStepper=https://github.com/trinamic/TMC26XStepper/archive/master.zip
+src_filter        = ${common.default_src_filter} +<src/HAL/HAL_AVR>
+
 #
 # Sanguinololu (ATmega644p)
 #
-- 
GitLab