Browse Source

BTT SKR V2.0 / Stepper Driver Anti-Reverse Protection (#21503)

Keith Bennett 3 years ago
parent
commit
69d85cce2d
No account linked to committer's email address

+ 9
- 0
Marlin/Configuration_adv.h View File

@@ -3388,6 +3388,15 @@
3388 3388
 #endif
3389 3389
 
3390 3390
 /**
3391
+ * Stepper Driver Anti-SNAFU Protection
3392
+ *
3393
+ * If the SAFE_POWER_PIN is defined for your board, Marlin will check
3394
+ * that stepper drivers are properly plugged in before applying power.
3395
+ * Disable protection if your stepper drivers don't support the feature.
3396
+ */
3397
+//#define DISABLE_DRIVER_SAFE_POWER_PROTECT
3398
+
3399
+/**
3391 3400
  * CNC Coordinate Systems
3392 3401
  *
3393 3402
  * Enables G53 and G54-G59.3 commands to select coordinate systems

+ 17
- 0
Marlin/src/MarlinCore.cpp View File

@@ -232,6 +232,10 @@
232 232
   #include "lcd/extui/lib/dgus/DGUSScreenHandler.h"
233 233
 #endif
234 234
 
235
+#if HAS_DRIVER_SAFE_POWER_PROTECT
236
+  #include "feature/stepper_driver_safety.h"
237
+#endif
238
+
235 239
 PGMSTR(M112_KILL_STR, "M112 Shutdown");
236 240
 
237 241
 MarlinState marlin_state = MF_INITIALIZING;
@@ -1223,6 +1227,15 @@ void setup() {
1223 1227
     SETUP_RUN(ui.reset_status());     // Load welcome message early. (Retained if no errors exist.)
1224 1228
   #endif
1225 1229
 
1230
+  #if PIN_EXISTS(SAFE_POWER)
1231
+    #if HAS_DRIVER_SAFE_POWER_PROTECT
1232
+      SETUP_RUN(stepper_driver_backward_check());
1233
+    #else
1234
+      SETUP_LOG("SAFE_POWER");
1235
+      OUT_WRITE(SAFE_POWER_PIN, HIGH);
1236
+    #endif
1237
+  #endif
1238
+
1226 1239
   #if ENABLED(PROBE_TARE)
1227 1240
     SETUP_RUN(probe.tare_init());
1228 1241
   #endif
@@ -1467,6 +1480,10 @@ void setup() {
1467 1480
     SETUP_RUN(test_tmc_connection(true, true, true, true));
1468 1481
   #endif
1469 1482
 
1483
+  #if HAS_DRIVER_SAFE_POWER_PROTECT
1484
+    SETUP_RUN(stepper_driver_backward_report());
1485
+  #endif
1486
+
1470 1487
   #if HAS_PRUSA_MMU2
1471 1488
     SETUP_RUN(mmu2.init());
1472 1489
   #endif

+ 19
- 18
Marlin/src/core/boards.h View File

@@ -363,25 +363,26 @@
363 363
 #define BOARD_BLACK_STM32F407VE       4204  // BLACK_STM32F407VE
364 364
 #define BOARD_BLACK_STM32F407ZE       4205  // BLACK_STM32F407ZE
365 365
 #define BOARD_STEVAL_3DP001V1         4206  // STEVAL-3DP001V1 3D PRINTER BOARD
366
-#define BOARD_BTT_SKR_PRO_V1_1        4207  // BigTreeTech SKR Pro v1.1 (STM32F407ZG)
367
-#define BOARD_BTT_SKR_PRO_V1_2        4208  // BigTreeTech SKR Pro v1.2 (STM32F407ZG)
368
-#define BOARD_BTT_BTT002_V1_0         4209  // BigTreeTech BTT002 v1.0 (STM32F407VG)
366
+#define BOARD_BTT_SKR_PRO_V1_1        4207  // BigTreeTech SKR Pro v1.1 (STM32F407ZGT6)
367
+#define BOARD_BTT_SKR_PRO_V1_2        4208  // BigTreeTech SKR Pro v1.2 (STM32F407ZGT6)
368
+#define BOARD_BTT_BTT002_V1_0         4209  // BigTreeTech BTT002 v1.0 (STM32F407VGT6)
369 369
 #define BOARD_BTT_E3_RRF              4210  // BigTreeTech E3 RRF (STM32F407VGT6)
370
-#define BOARD_BTT_GTR_V1_0            4211  // BigTreeTech GTR v1.0 (STM32F407IGT)
371
-#define BOARD_LERDGE_K                4212  // Lerdge K (STM32F407ZG)
372
-#define BOARD_LERDGE_S                4213  // Lerdge S (STM32F407VE)
373
-#define BOARD_LERDGE_X                4214  // Lerdge X (STM32F407VE)
374
-#define BOARD_VAKE403D                4215  // VAkE 403D (STM32F446VET6)
375
-#define BOARD_FYSETC_S6               4216  // FYSETC S6 (STM32F446VET6)
376
-#define BOARD_FYSETC_S6_V2_0          4217  // FYSETC S6 v2.0 (STM32F446VET6)
377
-#define BOARD_FYSETC_SPIDER           4218  // FYSETC Spider (STM32F446VET6)
378
-#define BOARD_FLYF407ZG               4219  // FLYF407ZG (STM32F407ZG)
379
-#define BOARD_MKS_ROBIN2              4220  // MKS_ROBIN2 (STM32F407ZE)
380
-#define BOARD_MKS_ROBIN_PRO_V2        4221  // MKS Robin Pro V2 (STM32F407VE)
381
-#define BOARD_MKS_ROBIN_NANO_V3       4222  // MKS Robin Nano V3 (STM32F407VG)
382
-#define BOARD_ANET_ET4                4223  // ANET ET4 V1.x (STM32F407VGT6)
383
-#define BOARD_ANET_ET4P               4224  // ANET ET4P V1.x (STM32F407VGT6)
384
-#define BOARD_FYSETC_CHEETAH_V20      4225  // FYSETC Cheetah V2.0
370
+#define BOARD_BTT_SKR_V2_0            4211  // BigTreeTech SKR v2.0 (STM32F407VGT6)
371
+#define BOARD_BTT_GTR_V1_0            4212  // BigTreeTech GTR v1.0 (STM32F407IGT)
372
+#define BOARD_LERDGE_K                4213  // Lerdge K (STM32F407ZG)
373
+#define BOARD_LERDGE_S                4214  // Lerdge S (STM32F407VE)
374
+#define BOARD_LERDGE_X                4215  // Lerdge X (STM32F407VE)
375
+#define BOARD_VAKE403D                4216  // VAkE 403D (STM32F446VET6)
376
+#define BOARD_FYSETC_S6               4217  // FYSETC S6 (STM32F446VET6)
377
+#define BOARD_FYSETC_S6_V2_0          4218  // FYSETC S6 v2.0 (STM32F446VET6)
378
+#define BOARD_FYSETC_SPIDER           4219  // FYSETC Spider (STM32F446VET6)
379
+#define BOARD_FLYF407ZG               4220  // FLYF407ZG (STM32F407ZG)
380
+#define BOARD_MKS_ROBIN2              4221  // MKS_ROBIN2 (STM32F407ZE)
381
+#define BOARD_MKS_ROBIN_PRO_V2        4222  // MKS Robin Pro V2 (STM32F407VE)
382
+#define BOARD_MKS_ROBIN_NANO_V3       4223  // MKS Robin Nano V3 (STM32F407VG)
383
+#define BOARD_ANET_ET4                4224  // ANET ET4 V1.x (STM32F407VGT6)
384
+#define BOARD_ANET_ET4P               4225 // ANET ET4P V1.x (STM32F407VGT6)
385
+#define BOARD_FYSETC_CHEETAH_V20      4226  // FYSETC Cheetah V2.0
385 386
 
386 387
 //
387 388
 // ARM Cortex M7

+ 171
- 0
Marlin/src/feature/stepper_driver_safety.cpp View File

@@ -0,0 +1,171 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../inc/MarlinConfig.h"
23
+#include "../lcd/marlinui.h"
24
+
25
+#if HAS_DRIVER_SAFE_POWER_PROTECT
26
+
27
+#include "stepper_driver_safety.h"
28
+
29
+static uint32_t axis_plug_backward = 0;
30
+
31
+void stepper_driver_backward_error(PGM_P str) {
32
+  SERIAL_ERROR_START();
33
+  SERIAL_ECHOPGM_P(str);
34
+  SERIAL_ECHOLNPGM(" driver is backward!");
35
+  ui.status_printf_P(2, PSTR(S_FMT S_FMT), str, GET_TEXT(MSG_DRIVER_BACKWARD));
36
+}
37
+
38
+void stepper_driver_backward_check() {
39
+
40
+  OUT_WRITE(SAFE_POWER_PIN, LOW);
41
+
42
+  #define TEST_BACKWARD(AXIS, BIT) do { \
43
+      SET_INPUT(AXIS##_ENABLE_PIN); \
44
+      OUT_WRITE(AXIS##_STEP_PIN, false); \
45
+      delay(20); \
46
+      if (READ(AXIS##_ENABLE_PIN) == false) { \
47
+        SBI(axis_plug_backward, BIT); \
48
+        stepper_driver_backward_error(PSTR(STRINGIFY(AXIS))); \
49
+      } \
50
+    }while(0)
51
+
52
+  #if HAS_X_ENABLE
53
+    TEST_BACKWARD(X, 0);
54
+  #endif
55
+  #if HAS_X2_ENABLE
56
+    TEST_BACKWARD(X2, 1);
57
+  #endif
58
+
59
+  #if HAS_Y_ENABLE
60
+    TEST_BACKWARD(Y, 2);
61
+  #endif
62
+  #if HAS_Y2_ENABLE
63
+    TEST_BACKWARD(Y2, 3);
64
+  #endif
65
+
66
+  #if HAS_Z_ENABLE
67
+    TEST_BACKWARD(Z, 4);
68
+  #endif
69
+  #if HAS_Z2_ENABLE
70
+    TEST_BACKWARD(Z2, 5);
71
+  #endif
72
+  #if HAS_Z3_ENABLE
73
+    TEST_BACKWARD(Z3, 6);
74
+  #endif
75
+  #if HAS_Z4_ENABLE
76
+    TEST_BACKWARD(Z4, 7);
77
+  #endif
78
+
79
+  #if HAS_E0_ENABLE
80
+    TEST_BACKWARD(E0, 8);
81
+  #endif
82
+  #if HAS_E1_ENABLE
83
+    TEST_BACKWARD(E1, 9);
84
+  #endif
85
+  #if HAS_E2_ENABLE
86
+    TEST_BACKWARD(E2, 10);
87
+  #endif
88
+  #if HAS_E3_ENABLE
89
+    TEST_BACKWARD(E3, 11);
90
+  #endif
91
+  #if HAS_E4_ENABLE
92
+    TEST_BACKWARD(E4, 12);
93
+  #endif
94
+  #if HAS_E5_ENABLE
95
+    TEST_BACKWARD(E5, 13);
96
+  #endif
97
+  #if HAS_E6_ENABLE
98
+    TEST_BACKWARD(E6, 14);
99
+  #endif
100
+  #if HAS_E7_ENABLE
101
+    TEST_BACKWARD(E7, 15);
102
+  #endif
103
+
104
+  if (!axis_plug_backward)
105
+    WRITE(SAFE_POWER_PIN, HIGH);
106
+}
107
+
108
+void stepper_driver_backward_report() {
109
+  if (!axis_plug_backward) return;
110
+
111
+  auto _report_if_backward = [](PGM_P axis, uint8_t bit) {
112
+    if (TEST(axis_plug_backward, bit))
113
+      stepper_driver_backward_error(axis);
114
+  };
115
+
116
+  #define REPORT_BACKWARD(axis, bit) _report_if_backward(PSTR(STRINGIFY(axis)), bit)
117
+
118
+  #if HAS_X_ENABLE
119
+    REPORT_BACKWARD(X, 0);
120
+  #endif
121
+  #if HAS_X2_ENABLE
122
+    REPORT_BACKWARD(X2, 1);
123
+  #endif
124
+
125
+  #if HAS_Y_ENABLE
126
+    REPORT_BACKWARD(Y, 2);
127
+  #endif
128
+  #if HAS_Y2_ENABLE
129
+    REPORT_BACKWARD(Y2, 3);
130
+  #endif
131
+
132
+  #if HAS_Z_ENABLE
133
+    REPORT_BACKWARD(Z, 4);
134
+  #endif
135
+  #if HAS_Z2_ENABLE
136
+    REPORT_BACKWARD(Z2, 5);
137
+  #endif
138
+  #if HAS_Z3_ENABLE
139
+    REPORT_BACKWARD(Z3, 6);
140
+  #endif
141
+  #if HAS_Z4_ENABLE
142
+    REPORT_BACKWARD(Z4, 7);
143
+  #endif
144
+
145
+  #if HAS_E0_ENABLE
146
+    REPORT_BACKWARD(E0, 8);
147
+  #endif
148
+  #if HAS_E1_ENABLE
149
+    REPORT_BACKWARD(E1, 9);
150
+  #endif
151
+  #if HAS_E2_ENABLE
152
+    REPORT_BACKWARD(E2, 10);
153
+  #endif
154
+  #if HAS_E3_ENABLE
155
+    REPORT_BACKWARD(E3, 11);
156
+  #endif
157
+  #if HAS_E4_ENABLE
158
+    REPORT_BACKWARD(E4, 12);
159
+  #endif
160
+  #if HAS_E5_ENABLE
161
+    REPORT_BACKWARD(E5, 13);
162
+  #endif
163
+  #if HAS_E6_ENABLE
164
+    REPORT_BACKWARD(E6, 14);
165
+  #endif
166
+  #if HAS_E7_ENABLE
167
+    REPORT_BACKWARD(E7, 15);
168
+  #endif
169
+}
170
+
171
+#endif // HAS_DRIVER_SAFE_POWER_PROTECT

+ 28
- 0
Marlin/src/feature/stepper_driver_safety.h View File

@@ -0,0 +1,28 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+
25
+#include "../inc/MarlinConfigPre.h"
26
+
27
+void stepper_driver_backward_check();
28
+void stepper_driver_backward_report();

+ 4
- 0
Marlin/src/inc/Conditionals_post.h View File

@@ -3042,3 +3042,7 @@
3042 3042
 #if BUTTONS_EXIST(EN1, EN2, ENC)
3043 3043
   #define HAS_ROTARY_ENCODER 1
3044 3044
 #endif
3045
+
3046
+#if PIN_EXISTS(SAFE_POWER) && DISABLED(DISABLE_DRIVER_SAFE_POWER_PROTECT)
3047
+  #define HAS_DRIVER_SAFE_POWER_PROTECT 1
3048
+#endif

+ 2
- 0
Marlin/src/lcd/language/language_en.h View File

@@ -706,6 +706,8 @@ namespace Language_en {
706 706
   PROGMEM Language_Str MSG_BOTTOM_RIGHT                    = _UxGT("Bottom Right");
707 707
   PROGMEM Language_Str MSG_CALIBRATION_COMPLETED           = _UxGT("Calibration Completed");
708 708
   PROGMEM Language_Str MSG_CALIBRATION_FAILED              = _UxGT("Calibration Failed");
709
+
710
+  PROGMEM Language_Str MSG_DRIVER_BACKWARD                 = _UxGT(" driver backward");
709 711
 }
710 712
 
711 713
 #if FAN_COUNT == 1

+ 2
- 0
Marlin/src/pins/pins.h View File

@@ -596,6 +596,8 @@
596 596
   #include "stm32f4/pins_BTT_BTT002_V1_0.h"     // STM32F4                                env:BIGTREE_BTT002
597 597
 #elif MB(BTT_E3_RRF)
598 598
   #include "stm32f4/pins_BTT_E3_RRF.h"          // STM32F4                                env:BIGTREE_E3_RRF
599
+#elif MB(BTT_SKR_V2_0)
600
+  #include "stm32f4/pins_BTT_SKR_V2_0.h"        // STM32F4                                env:BIGTREE_SKR_2
599 601
 #elif MB(LERDGE_K)
600 602
   #include "stm32f4/pins_LERDGE_K.h"            // STM32F4                                env:LERDGEK env:LERDGEK_usb_flash_drive
601 603
 #elif MB(LERDGE_S)

+ 495
- 0
Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0.h View File

@@ -0,0 +1,495 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include "env_validate.h"
25
+
26
+#define BOARD_INFO_NAME "BTT SKR V2.0"
27
+
28
+// Use one of these or SDCard-based Emulation will be used
29
+#if NO_EEPROM_SELECTED
30
+  //#define SRAM_EEPROM_EMULATION                 // Use BackSRAM-based EEPROM emulation
31
+  #define FLASH_EEPROM_EMULATION                  // Use Flash-based EEPROM emulation
32
+#endif
33
+
34
+#if ENABLED(FLASH_EEPROM_EMULATION)
35
+  // Decrease delays and flash wear by spreading writes across the
36
+  // 128 kB sector allocated for EEPROM emulation.
37
+  #define FLASH_EEPROM_LEVELING
38
+#endif
39
+
40
+// USB Flash Drive support
41
+#define HAS_OTG_USB_HOST_SUPPORT
42
+
43
+// Avoid conflict with TIMER_TONE
44
+#define STEP_TIMER                            10
45
+
46
+//
47
+// Servos
48
+//
49
+#define SERVO0_PIN                          PE5
50
+
51
+//
52
+// Trinamic Stallguard pins
53
+//
54
+#define X_DIAG_PIN                          PC1   // X-STOP
55
+#define Y_DIAG_PIN                          PC3   // Y-STOP
56
+#define Z_DIAG_PIN                          PC0   // Z-STOP
57
+#define E0_DIAG_PIN                         PC2   // E0DET
58
+#define E1_DIAG_PIN                         PA0   // E1DET
59
+
60
+//
61
+// Limit Switches
62
+//
63
+#ifdef X_STALL_SENSITIVITY
64
+  #define X_STOP_PIN                  X_DIAG_PIN
65
+  #if X_HOME_DIR < 0
66
+    #define X_MAX_PIN                       PC2   // E0DET
67
+  #else
68
+    #define X_MIN_PIN                       PC2   // E0DET
69
+  #endif
70
+#elif ENABLED(X_DUAL_ENDSTOPS)
71
+  #ifndef X_MIN_PIN
72
+    #define X_MIN_PIN                       PC1   // X-STOP
73
+  #endif
74
+  #ifndef X_MAX_PIN
75
+    #define X_MAX_PIN                       PC2   // E0DET
76
+  #endif
77
+#else
78
+  #define X_STOP_PIN                        PC1   // X-STOP
79
+#endif
80
+
81
+#ifdef Y_STALL_SENSITIVITY
82
+  #define Y_STOP_PIN                  Y_DIAG_PIN
83
+  #if Y_HOME_DIR < 0
84
+    #define Y_MAX_PIN                       PA0   // E1DET
85
+  #else
86
+    #define Y_MIN_PIN                       PA0   // E1DET
87
+  #endif
88
+#elif ENABLED(Y_DUAL_ENDSTOPS)
89
+  #ifndef Y_MIN_PIN
90
+    #define Y_MIN_PIN                       PC3   // Y-STOP
91
+  #endif
92
+  #ifndef Y_MAX_PIN
93
+    #define Y_MAX_PIN                       PA0   // E1DET
94
+  #endif
95
+#else
96
+  #define Y_STOP_PIN                        PC3   // Y-STOP
97
+#endif
98
+
99
+#ifdef Z_STALL_SENSITIVITY
100
+  #define Z_STOP_PIN                  Z_DIAG_PIN
101
+  #if Z_HOME_DIR < 0
102
+    #define Z_MAX_PIN                       PC15  // PWRDET
103
+  #else
104
+    #define Z_MIN_PIN                       PC15  // PWRDET
105
+  #endif
106
+#elif ENABLED(Z_MULTI_ENDSTOPS)
107
+  #ifndef Z_MIN_PIN
108
+    #define Z_MIN_PIN                       PC0   // Z-STOP
109
+  #endif
110
+  #ifndef Z_MAX_PIN
111
+    #define Z_MAX_PIN                       PC15  // PWRDET
112
+  #endif
113
+#else
114
+  #ifndef Z_STOP_PIN
115
+    #define Z_STOP_PIN                      PC0   // Z-STOP
116
+  #endif
117
+#endif
118
+
119
+//
120
+// Z Probe (when not Z_MIN_PIN)
121
+//
122
+#ifndef Z_MIN_PROBE_PIN
123
+  #define Z_MIN_PROBE_PIN                   PE4
124
+#endif
125
+
126
+//
127
+// Filament Runout Sensor
128
+//
129
+#define FIL_RUNOUT_PIN                      PC2   // E0DET
130
+#define FIL_RUNOUT2_PIN                     PA0   // E1DET
131
+
132
+//
133
+// Power Supply Control
134
+//
135
+#ifndef PS_ON_PIN
136
+  #define PS_ON_PIN                         PE8   // PS-ON
137
+#endif
138
+
139
+//
140
+// Power Loss Detection
141
+//
142
+#ifndef POWER_LOSS_PIN
143
+  #define POWER_LOSS_PIN                    PC15  // PWRDET
144
+#endif
145
+
146
+//
147
+// NeoPixel LED
148
+//
149
+#ifndef NEOPIXEL_PIN
150
+  #define NEOPIXEL_PIN                      PE6
151
+#endif
152
+
153
+//
154
+// Control pin of driver/heater/fan power supply
155
+//
156
+#define SAFE_POWER_PIN                      PC13
157
+
158
+//
159
+// Steppers
160
+//
161
+#define X_STEP_PIN                          PE2
162
+#define X_DIR_PIN                           PE1
163
+#define X_ENABLE_PIN                        PE3
164
+#ifndef X_CS_PIN
165
+  #define X_CS_PIN                          PE0
166
+#endif
167
+
168
+#define Y_STEP_PIN                          PD5
169
+#define Y_DIR_PIN                           PD4
170
+#define Y_ENABLE_PIN                        PD6
171
+#ifndef Y_CS_PIN
172
+  #define Y_CS_PIN                          PD3
173
+#endif
174
+
175
+#define Z_STEP_PIN                          PA15
176
+#define Z_DIR_PIN                           PA8
177
+#define Z_ENABLE_PIN                        PD1
178
+#ifndef Z_CS_PIN
179
+  #define Z_CS_PIN                          PD0
180
+#endif
181
+
182
+#define E0_STEP_PIN                         PD15
183
+#define E0_DIR_PIN                          PD14
184
+#define E0_ENABLE_PIN                       PC7
185
+#ifndef E0_CS_PIN
186
+  #define E0_CS_PIN                         PC6
187
+#endif
188
+
189
+#define E1_STEP_PIN                         PD11
190
+#define E1_DIR_PIN                          PD10
191
+#define E1_ENABLE_PIN                       PD13
192
+#ifndef E1_CS_PIN
193
+  #define E1_CS_PIN                         PD12
194
+#endif
195
+
196
+//
197
+// Temperature Sensors
198
+//
199
+#define TEMP_BED_PIN                        PA1   // TB
200
+#define TEMP_0_PIN                          PA2   // TH0
201
+#define TEMP_1_PIN                          PA3   // TH1
202
+
203
+//
204
+// Heaters / Fans
205
+//
206
+#define HEATER_0_PIN                        PB3   // Heater0
207
+#define HEATER_1_PIN                        PB4   // Heater1
208
+#define HEATER_BED_PIN                      PD7   // Hotbed
209
+#define FAN_PIN                             PB7   // Fan0
210
+#define FAN1_PIN                            PB6   // Fan1
211
+#define FAN2_PIN                            PB5   // Fan2
212
+
213
+//
214
+// Software SPI pins for TMC2130 stepper drivers
215
+//
216
+#if ENABLED(TMC_USE_SW_SPI)
217
+  #ifndef TMC_SW_MOSI
218
+    #define TMC_SW_MOSI                     PE14
219
+  #endif
220
+  #ifndef TMC_SW_MISO
221
+    #define TMC_SW_MISO                     PA14
222
+  #endif
223
+  #ifndef TMC_SW_SCK
224
+    #define TMC_SW_SCK                      PE15
225
+  #endif
226
+#endif
227
+
228
+#if HAS_TMC_UART
229
+  /**
230
+   * TMC2208/TMC2209 stepper drivers
231
+   *
232
+   * Hardware serial communication ports.
233
+   * If undefined software serial is used according to the pins below
234
+   */
235
+  //#define X_HARDWARE_SERIAL  Serial1
236
+  //#define X2_HARDWARE_SERIAL Serial1
237
+  //#define Y_HARDWARE_SERIAL  Serial1
238
+  //#define Y2_HARDWARE_SERIAL Serial1
239
+  //#define Z_HARDWARE_SERIAL  Serial1
240
+  //#define Z2_HARDWARE_SERIAL Serial1
241
+  //#define E0_HARDWARE_SERIAL Serial1
242
+  //#define E1_HARDWARE_SERIAL Serial1
243
+  //#define E2_HARDWARE_SERIAL Serial1
244
+  //#define E3_HARDWARE_SERIAL Serial1
245
+  //#define E4_HARDWARE_SERIAL Serial1
246
+
247
+  //
248
+  // Software serial
249
+  //
250
+  #define X_SERIAL_TX_PIN                   PE0
251
+  #define X_SERIAL_RX_PIN                   PE0
252
+
253
+  #define Y_SERIAL_TX_PIN                   PD3
254
+  #define Y_SERIAL_RX_PIN                   PD3
255
+
256
+  #define Z_SERIAL_TX_PIN                   PD0
257
+  #define Z_SERIAL_RX_PIN                   PD0
258
+
259
+  #define E0_SERIAL_TX_PIN                  PC6
260
+  #define E0_SERIAL_RX_PIN                  PC6
261
+
262
+  #define E1_SERIAL_TX_PIN                  PD12
263
+  #define E1_SERIAL_RX_PIN                  PD12
264
+
265
+  // Reduce baud rate to improve software serial reliability
266
+  #define TMC_BAUD_RATE                    19200
267
+#endif
268
+
269
+//
270
+// SD Connection
271
+//
272
+#ifndef SDCARD_CONNECTION
273
+  #define SDCARD_CONNECTION LCD
274
+#endif
275
+
276
+/**
277
+ *               -----                                             -----
278
+ *           NC | 1 2 | GND                                    5V | 1 2 | GND
279
+ *        RESET | 3 4 | PC4 (SD_DETECT)             (LCD_D7) PE13 | 3 4 | PE12 (LCD_D6)
280
+ *   (MOSI) PA7 | 5 6   PB2 (BTN_EN2)               (LCD_D5) PE11 | 5 6   PE10 (LCD_D4)
281
+ *  (SD_SS) PA4 | 7 8 | PE7 (BTN_EN1)               (LCD_RS)  PE9 | 7 8 | PB1  (LCD_EN)
282
+ *    (SCK) PA5 | 9 10| PA6 (MISO)                 (BTN_ENC)  PB0 | 9 10| PC5  (BEEPER)
283
+ *               -----                                             -----
284
+ *               EXP2                                              EXP1
285
+ */
286
+
287
+#define EXP1_03_PIN                         PE13
288
+#define EXP1_04_PIN                         PE12
289
+#define EXP1_05_PIN                         PE11
290
+#define EXP1_06_PIN                         PE10
291
+#define EXP1_07_PIN                         PE9
292
+#define EXP1_08_PIN                         PB1
293
+#define EXP1_09_PIN                         PB0
294
+#define EXP1_10_PIN                         PC5
295
+
296
+#define EXP2_03_PIN                         -1
297
+#define EXP2_04_PIN                         PC4
298
+#define EXP2_05_PIN                         PA7
299
+#define EXP2_06_PIN                         PB2
300
+#define EXP2_07_PIN                         PA4
301
+#define EXP2_08_PIN                         PE7
302
+#define EXP2_09_PIN                         PA5
303
+#define EXP2_10_PIN                         PA6
304
+
305
+//
306
+// Onboard SD card
307
+// Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2
308
+//
309
+#if SD_CONNECTION_IS(ONBOARD)
310
+
311
+  #define SDIO_SUPPORT                            // Use SDIO for onboard SD
312
+  #define SDIO_D0_PIN                       PC8
313
+  #define SDIO_D1_PIN                       PC9
314
+  #define SDIO_D2_PIN                       PC10
315
+  #define SDIO_D3_PIN                       PC11
316
+  #define SDIO_CK_PIN                       PC12
317
+  #define SDIO_CMD_PIN                      PD2
318
+
319
+#elif SD_CONNECTION_IS(LCD)
320
+
321
+  #define CUSTOM_SPI_PINS
322
+  #define SDSS                              PA4
323
+  #define SD_SS_PIN                         SDSS
324
+  #define SD_SCK_PIN                        PA5
325
+  #define SD_MISO_PIN                       PA6
326
+  #define SD_MOSI_PIN                       PA7
327
+  #define SD_DETECT_PIN                     PC4
328
+
329
+#elif SD_CONNECTION_IS(CUSTOM_CABLE)
330
+  #error "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for this board"
331
+#endif
332
+
333
+#if ENABLED(BTT_MOTOR_EXPANSION)
334
+  /**
335
+   *               _____                                      _____
336
+   *           NC | · · | GND                             NC | · · | GND
337
+   *           NC | · · | PF12 (M1EN)            (M2EN)  PG7 | · · | PG6  (M3EN)
338
+   * (M1STP) PB15 | · ·   PF11 (M1DIR)           (M1RX)  PG3 | · ·   PG2  (M1DIAG)
339
+   * (M2DIR) PB12 | · · | PG10 (M2STP)           (M2RX) PD10 | · · | PD11 (M2DIAG)
340
+   * (M3DIR) PB13 | · · | PB14 (M3STP)           (M3RX)  PA8 | · · | PG4  (M3DIAG)
341
+   *               -----                                      -----
342
+   *               EXP2                                       EXP1
343
+   */
344
+
345
+  // M1 on Driver Expansion Module
346
+  #define E3_STEP_PIN                EXP2_05_PIN
347
+  #define E3_DIR_PIN                 EXP2_06_PIN
348
+  #define E3_ENABLE_PIN              EXP2_04_PIN
349
+  #define E3_DIAG_PIN                EXP1_06_PIN
350
+  #define E3_CS_PIN                  EXP1_05_PIN
351
+  #if HAS_TMC_UART
352
+    #define E3_SERIAL_TX_PIN         EXP1_05_PIN
353
+    #define E3_SERIAL_RX_PIN         EXP1_05_PIN
354
+  #endif
355
+
356
+  // M2 on Driver Expansion Module
357
+  #define E4_STEP_PIN                EXP2_08_PIN
358
+  #define E4_DIR_PIN                 EXP2_07_PIN
359
+  #define E4_ENABLE_PIN              EXP1_03_PIN
360
+  #define E4_DIAG_PIN                EXP1_08_PIN
361
+  #define E4_CS_PIN                  EXP1_07_PIN
362
+  #if HAS_TMC_UART
363
+    #define E4_SERIAL_TX_PIN         EXP1_07_PIN
364
+    #define E4_SERIAL_RX_PIN         EXP1_07_PIN
365
+  #endif
366
+
367
+  // M3 on Driver Expansion Module
368
+  #define E5_STEP_PIN                EXP2_10_PIN
369
+  #define E5_DIR_PIN                 EXP2_09_PIN
370
+  #define E5_ENABLE_PIN              EXP1_04_PIN
371
+  #define E5_DIAG_PIN                EXP1_10_PIN
372
+  #define E5_CS_PIN                  EXP1_09_PIN
373
+  #if HAS_TMC_UART
374
+    #define E5_SERIAL_TX_PIN         EXP1_09_PIN
375
+    #define E5_SERIAL_RX_PIN         EXP1_09_PIN
376
+  #endif
377
+
378
+#endif // BTT_MOTOR_EXPANSION
379
+
380
+//
381
+// LCDs and Controllers
382
+//
383
+#if IS_TFTGLCD_PANEL
384
+
385
+  #if ENABLED(TFTGLCD_PANEL_SPI)
386
+    #define TFTGLCD_CS               EXP2_08_PIN
387
+  #endif
388
+
389
+#elif HAS_WIRED_LCD
390
+
391
+  #define BEEPER_PIN                 EXP1_10_PIN
392
+  #define BTN_ENC                    EXP1_09_PIN
393
+
394
+  #if ENABLED(CR10_STOCKDISPLAY)
395
+
396
+    #define LCD_PINS_RS              EXP1_04_PIN
397
+
398
+    #define BTN_EN1                  EXP1_08_PIN
399
+    #define BTN_EN2                  EXP1_06_PIN
400
+
401
+    #define LCD_PINS_ENABLE          EXP1_03_PIN
402
+    #define LCD_PINS_D4              EXP1_05_PIN
403
+
404
+    // CR10_STOCKDISPLAY default timing is too fast
405
+    #undef BOARD_ST7920_DELAY_1
406
+    #undef BOARD_ST7920_DELAY_2
407
+    #undef BOARD_ST7920_DELAY_3
408
+
409
+  #elif ENABLED(MKS_MINI_12864)
410
+
411
+    #define DOGLCD_A0                EXP1_04_PIN
412
+    #define DOGLCD_CS                EXP1_05_PIN
413
+    #define BTN_EN1                  EXP2_08_PIN
414
+    #define BTN_EN2                  EXP2_06_PIN
415
+
416
+  #else
417
+
418
+    #define LCD_PINS_RS              EXP1_07_PIN
419
+
420
+    #define BTN_EN1                  EXP2_08_PIN
421
+    #define BTN_EN2                  EXP2_06_PIN
422
+
423
+    #define LCD_PINS_ENABLE          EXP1_08_PIN
424
+    #define LCD_PINS_D4              EXP1_06_PIN
425
+
426
+    #if ENABLED(FYSETC_MINI_12864)
427
+      #define DOGLCD_CS              EXP1_08_PIN
428
+      #define DOGLCD_A0              EXP1_07_PIN
429
+      //#define LCD_BACKLIGHT_PIN           -1
430
+      #define LCD_RESET_PIN          EXP1_06_PIN  // Must be high or open for LCD to operate normally.
431
+      #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
432
+        #ifndef RGB_LED_R_PIN
433
+          #define RGB_LED_R_PIN      EXP1_05_PIN
434
+        #endif
435
+        #ifndef RGB_LED_G_PIN
436
+          #define RGB_LED_G_PIN      EXP1_04_PIN
437
+        #endif
438
+        #ifndef RGB_LED_B_PIN
439
+          #define RGB_LED_B_PIN      EXP1_03_PIN
440
+        #endif
441
+      #elif ENABLED(FYSETC_MINI_12864_2_1)
442
+        #define NEOPIXEL_PIN         EXP1_05_PIN
443
+      #endif
444
+    #endif // !FYSETC_MINI_12864
445
+
446
+    #if IS_ULTIPANEL
447
+      #define LCD_PINS_D5            EXP1_05_PIN
448
+      #define LCD_PINS_D6            EXP1_04_PIN
449
+      #define LCD_PINS_D7            EXP1_03_PIN
450
+
451
+      #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
452
+        #define BTN_ENC_EN           LCD_PINS_D7  // Detect the presence of the encoder
453
+      #endif
454
+
455
+    #endif
456
+
457
+  #endif
458
+
459
+#endif // HAS_WIRED_LCD
460
+
461
+// Alter timing for graphical display
462
+#if HAS_MARLINUI_U8GLIB
463
+  #ifndef BOARD_ST7920_DELAY_1
464
+    #define BOARD_ST7920_DELAY_1    DELAY_NS(96)
465
+  #endif
466
+  #ifndef BOARD_ST7920_DELAY_2
467
+    #define BOARD_ST7920_DELAY_2    DELAY_NS(48)
468
+  #endif
469
+  #ifndef BOARD_ST7920_DELAY_3
470
+    #define BOARD_ST7920_DELAY_3   DELAY_NS(600)
471
+  #endif
472
+#endif
473
+
474
+//
475
+// WIFI
476
+//
477
+
478
+/**
479
+ *                      -------
480
+ *            GND | 9  |       | 8 | 3.3V
481
+ *  (ESP-CS) PB12 | 10 |       | 7 | PB15 (ESP-MOSI)
482
+ *           3.3V | 11 |       | 6 | PB14 (ESP-MISO)
483
+ * (ESP-IO0) PB10 | 12 |       | 5 | PB13 (ESP-CLK)
484
+ * (ESP-IO4) PB11 | 13 |       | 4 | NC
485
+ *             NC | 14 |       | 3 | 3.3V (ESP-EN)
486
+ *  (ESP-RX)  PD8 | 15 |       | 2 | NC
487
+ *  (ESP-TX)  PD9 | 16 |       | 1 | PC14 (ESP-RST)
488
+ *                      -------
489
+ *                       WIFI
490
+ */
491
+#define ESP_WIFI_MODULE_COM                    3  // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this
492
+#define ESP_WIFI_MODULE_BAUDRATE        BAUDRATE  // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2
493
+#define ESP_WIFI_MODULE_RESET_PIN           PC14
494
+#define ESP_WIFI_MODULE_GPIO0_PIN           PB10
495
+#define ESP_WIFI_MODULE_GPIO4_PIN           PB11

+ 1
- 0
ini/features.ini View File

@@ -134,6 +134,7 @@ HAS_FILAMENT_SENSOR     = src_filter=+<src/feature/runout.cpp> +<src/gcode/featu
134 134
 (EXT|MANUAL)_SOLENOID.* = src_filter=+<src/feature/solenoid.cpp> +<src/gcode/control/M380_M381.cpp>
135 135
 MK2_MULTIPLEXER         = src_filter=+<src/feature/snmm.cpp>
136 136
 HAS_CUTTER              = src_filter=+<src/feature/spindle_laser.cpp> +<src/gcode/control/M3-M5.cpp>
137
+HAS_DRIVER_SAFE_POWER_PROTECT = src_filter=+<src/feature/stepper_driver_safety.cpp>
137 138
 EXPERIMENTAL_I2CBUS     = src_filter=+<src/feature/twibus.cpp> +<src/gcode/feature/i2c>
138 139
 MECHANICAL_GANTRY_CAL.+ = src_filter=+<src/gcode/calibrate/G34.cpp>
139 140
 Z_MULTI_ENDSTOPS        = src_filter=+<src/gcode/calibrate/G34_M422.cpp>

+ 20
- 0
ini/stm32f4.ini View File

@@ -226,6 +226,26 @@ extra_scripts     = ${common.extra_scripts}
226 226
   pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
227 227
 
228 228
 #
229
+# Bigtreetech SKR V2.0 (STM32F407VGT6 ARM Cortex-M4) with USB Flash Drive Support
230
+#
231
+[env:BIGTREE_SKR_2]
232
+platform             = ${common_stm32.platform}
233
+platform_packages    = ${stm_flash_drive.platform_packages}
234
+extends              = common_stm32
235
+board                = genericSTM32F407VGT6
236
+board_build.core     = stm32
237
+board_build.variant  = MARLIN_F4x7Vx
238
+board_build.ldscript = ldscript.ld
239
+board_build.offset   = 0x8000
240
+board_upload.offset_address = 0x08008000
241
+extra_scripts     = ${common.extra_scripts}
242
+  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
243
+  buildroot/share/PlatformIO/scripts/stm32_bootloader.py
244
+build_flags       = ${stm_flash_drive.build_flags}
245
+  -DUSE_USBHOST_HS -DUSE_USB_HS_IN_FS -DUSBD_IRQ_PRIO=5 -DUSBD_IRQ_SUBPRIO=6
246
+  -DHSE_VALUE=8000000U -DHAL_SD_MODULE_ENABLED
247
+
248
+#
229 249
 # Lerdge base
230 250
 #
231 251
 [lerdge_common]

+ 1
- 0
platformio.ini View File

@@ -136,6 +136,7 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
136 136
   -<src/feature/snmm.cpp>
137 137
   -<src/feature/solenoid.cpp> -<src/gcode/control/M380_M381.cpp>
138 138
   -<src/feature/spindle_laser.cpp> -<src/gcode/control/M3-M5.cpp>
139
+  -<src/feature/stepper_driver_safety.cpp>
139 140
   -<src/feature/tmc_util.cpp> -<src/module/stepper/trinamic.cpp>
140 141
   -<src/feature/tramming.cpp>
141 142
   -<src/feature/twibus.cpp>

Loading…
Cancel
Save